From b96a9c6ce7cde8cd41c90bcffa7c2ad507fcc111 Mon Sep 17 00:00:00 2001 From: huangxin Date: Thu, 23 Apr 2020 19:30:21 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E4=BF=AE=E6=AD=A3=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=AE=A1=E7=90=86=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/com/dispose/controller/TaskControllerTest.java | 4 ++++ 1 file changed, 4 insertions(+) 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;