-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
Spring boot versions: 2.5.3
testcontainers version: 1.16.2
Added dependencies:
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
When I run the below integration test it gives the following error:
com.github.dockerjava.api.exception.NotFoundException: Status 404: {"message":"No such container: 28b30f05bc53b19fae5f11daa9244e28f1eca57ceee6eb11558f1e730341c7f1"}
@ActiveProfiles("it")
@Testcontainers
//@formatter:off
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = RestApplication.class) //@formatter:on
@TestInstance(TestInstance.Lifecycle.PER_METHOD)
class DummyResourceIT {
private static String BASE_PATH;
@Container
public static PostgreSQLContainer container = new PostgreSQLContainer("postgres:latest")
.withUsername("dummyusername")
.withPassword("dummypassword")
.withDatabaseName("dummydb");
@DynamicPropertySource
static void properties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", container::getJdbcUrl);
registry.add("spring.datasource.username", container::getUsername);
registry.add("spring.datasource.password", container::getPassword);
}
@LocalServerPort
private int serverPort;
@BeforeEach
void setUp() {
BASE_PATH = "http://localhost:" + serverPort + "/api";
}
@Test()
void should_pass() {
String url = BASE_PATH + "/v1/dummy";
//@formatter:off
given()
.contentType(MediaType.APPLICATION_JSON_VALUE)
.when()
.get(url)
.then()
.statusCode(200)
.log()
.all()
.body("size()", Matchers.equalTo(0));
//@formatter:on
}
What I'm doing wrong!?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels