This repository was archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
This repository was archived by the owner on Sep 6, 2024. It is now read-only.
Spring Boot Integration Tests support ? #100
Copy link
Copy link
Open
Description
Might have been already touched upon the matter (please point me in the right direction if so), but I'm having troubles using this with Spring boot integration tests.
Code excerpt:
@Docker(image = "postgres", ports = @Port(inner = 5432, exposed = 5432),
environments = {
@Environment(key = "POSTGRES_DB", value = "test-db"),
@Environment(key = "POSTGRES_USER", value = "test-user"),
@Environment(key = "POSTGRES_PASSWORD", value = "test-password")
},
waitFor = @WaitFor(value = "PostgreSQL init process complete;"))
@SpringBootTest
@ExtendWith(SpringExtension.class)
@TestInstance(Lifecycle.PER_CLASS)
class UserControllerIntegrationTest {
private @Autowired WebApplicationContext wac;
private @Autowired UserRepository userRepository;
private MockMvc mockMvc;
private ObjectMapper objectMapper = new ObjectMapper();
@BeforeAll
void setUpTest () {
mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
objectMapper.setFilterProvider(new SimpleFilterProvider()
.setFailOnUnknownId(false)
);
}
@Test
@WithUserDetails("batman@gotham-city.com")
void getUserListTest() throws Exception {
mockMvc.perform(get("/users"))
.andDo(print())
.andExpect(status().is2xxSuccessful())
.andExpect(jsonPath("$.content").isArray())
.andExpect(jsonPath("$.content").isNotEmpty());
}
}
What I have observed is that when I'm adding @SpringBootTest annotation, the DockerExtension doesn't kick in no more - there is no traceable call to DockerExtension.beforeAll. Without it, it works, but then my tests config will fail...
I would love to be able to use this annotation - @Docker with my integration tests. Please help ?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels