Skip to content

[Feature]: JUnit Jupiter extension for reuse of containers #6401

Open
@hendrikebbers

Description

@hendrikebbers

Module

Core

Problem

Assume you have several integration tests splitted in some classes. All this tests can reuse the same container instance. If the container needs some time to setup that would be a great benefit.

Solution

By using the JUnit extension API it would be easy to create a custom annotation like this:

@ContainerConfig(name="containerA", needNewInstance=false) public void testFoo() {}

A container that is needed could be simply defined by a provider:

@ContainerProvider(name="containerA") public GenericContainer<?> createContainerA() {}

By using test lifecycle callbacks (https://junit.org/junit5/docs/current/user-guide/#extensions-lifecycle-callbacks) this could be achieved as a JUnit extension.

I would be happy to help by creating the feature :)

Benefit

Containers that are needed for multiple tests in multiple classes only need to be defined once and the instances can be reused.

Alternatives

Would you like to help contributing this feature?

Yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions