diff --git a/src/test/java/com/dispose/controller/TaskControllerTest.java b/src/test/java/com/dispose/controller/TaskControllerTest.java index ff9d0ef6..64c76b6b 100644 --- a/src/test/java/com/dispose/controller/TaskControllerTest.java +++ b/src/test/java/com/dispose/controller/TaskControllerTest.java @@ -14,7 +14,9 @@ import javax.annotation.Resource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; @@ -27,6 +29,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @AutoConfigureMockMvc @RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) public class TaskControllerTest extends InitTestEnvironment { @Resource private MockMvc mockMvc;