I'd like to use a container shared among tests as early in a BeforeAll method like this:
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
@Testcontainers
public class SomeTest {
@Container
private static final GenericContainer aContainer = new GenericContainer("postgres:9");
@BeforeAll
static void doSomethingWithAContainer() {
Assertions.assertTrue(aContainer.isRunning());
}
@Test
void aTest() {
Assertions.assertTrue(aContainer.isRunning());
}
}
I deliberately used a generic container here, but the result is the same with dedicated once, too.
The use case is providing fixtures etc. I wonder if implementing the BeforeAllCallback as it was done beforehand in #887 would have been the better approach, as it should have kept the order (first extensions, than concrete BeforeAll).
I'd like to use a container shared among tests as early in a
BeforeAllmethod like this:I deliberately used a generic container here, but the result is the same with dedicated once, too.
The use case is providing fixtures etc. I wonder if implementing the
BeforeAllCallbackas it was done beforehand in #887 would have been the better approach, as it should have kept the order (first extensions, than concreteBeforeAll).