Running controller test classes in order.
I have this test classes below.
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc(addFilters = false)
public class UserControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
public void findAll() throws Exception {
MvcResult result = mockMvc
.perform(get("/api/user").contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andReturn();
MockHttpServletResponse response = result.getResponse();
RestResponse restResponse = mapper.readValue(response.getContentAsString(), RestResponse.class);
Assert.assertEquals(restResponse.getHttpStatus().name(), HttpStatus.OK.name() );
}
}
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc(addFilters = false)
public class ProductControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
public void findAll() throws Exception {
MvcResult result = mockMvc
.perform(get("/api/product").contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andReturn();
MockHttpServletResponse response = result.getResponse();
RestResponse restResponse = mapper.readValue(response.getContentAsString(), RestResponse.class);
Assert.assertEquals(restResponse.getHttpStatus().name(), HttpStatus.OK.name() );
}
}
I want to run this controller test classes in order. For example, first UserControllerTest runs after that ProductControllerTest.
How can i do this?
Thank you.