Skip to content

Allow testcontainer beans to also contribute properties #35201

@philwebb

Description

@philwebb

When using testcontainers at development time @DynamicPropertySource is not an option. If you're working with a container that can't use @ServiceConnection then things are of limited use.

Chatting to @bsideup, he suggested the idea of a container factory that could create the container but also do other things.

@Bean
ContainerFactory<MyContainer> myContainer() {
    return ContainerFactory.of(MyContainer::new).withProperties(container -> return Map.of("some.property", container.getSomethingDynamic()));
}

Another option might be some kind of annotation to contribute things.

Metadata

Metadata

Assignees

No one assigned

    Labels

    theme: containersTestcontainers, Docker Compose and Buildpack featurestype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions