@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) and @AutoConfigureMockMvc at the same time seems to be an anti-pattern

17 Views Asked by At

I am currently studying the usage of these two annotations:

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc

I saw a code base which looks like:

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
class LoginEndToEndTest {

   @Autowired protected MockMvc mvc;

isn't it an bad/anti pattern?

In fact,

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)

seems to be used to launch a real embedded servlet container, while @AutoConfigureMockMvc is used to make... mocks!

So, are these 2 annotations are compatible at the same time?

thanks.

0

There are 0 best solutions below