I have this abstract class for IT tests:
@RunWith(SpringRunner.class)
@Import(DbUnitConfig.class)
@SpringBootTest(classes = App.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@DbUnitConfiguration(dataSetLoader = DbUnitDataSetLoader.class)
@TestExecutionListeners({
DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class,
TransactionalTestExecutionListener.class,
DbUnitTestExecutionListener.class
})
public abstract class AbstractIT {
@ClassRule
public static final DockerComposeContainer postgres =
new DockerComposeContainer(new File("src/test/resources/docker-compose-postgres.yml"))
.withExposedService("cars-user-postgres-it", 5432);
}
when i'm launching only one instance of IT test class, it works OK.
But when i'm launching multiple test classes, one the first will complete, other will fail because of shut down postgres
this is the log from Container:
Stopping 1ykxuc_postgres-it_1 ...
Stopping 1ykxucpostgres-it_1 ... done
Removing 1ykxuc_postgres-it_1 ...
Removing 1ykxuc_cars-user-postgres-it_1 ... done
Removing network 1ykxuc_default
how to tell TestContainers not to stop containers after one class execution, but when all of them finished?