Code: Select all
@SuppressWarnings("PMD.TestClassWithoutTestCases")
@TestConfiguration(proxyBeanMethods = false)
public class TestcontainersConfiguration {
@Bean
@ServiceConnection
PostgreSQLContainer sharedDatabaseContainer() {
return new PostgreSQLContainer(DockerImageName.parse("postgres:17.2"))
.withDatabaseName("").withUsername("").withPassword("")
.withCommand("postgres", "-c", "log_statement=all") // this seems to be ignored
.withExposedPorts(1234);
}
}
< /code>
Und hier ist, wie ich diese Konfiguration in meiner Testklasse verwende: < /p>
@Import(TestcontainersConfiguration.class)
@SpringBootTest
@Tag("UnitTest")
public class RepositoryTest {
...
}