|
@@ -0,0 +1,37 @@
|
|
|
+package com.alvin.controller;
|
|
|
+
|
|
|
+import org.junit.After;
|
|
|
+import org.junit.Before;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+import org.springframework.test.context.web.WebAppConfiguration;
|
|
|
+import org.springframework.test.web.servlet.MockMvc;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 测试基础类,建议测试service层
|
|
|
+ *
|
|
|
+ * @author tianyunperfect
|
|
|
+ * @date 2020/05/20
|
|
|
+ */
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
+@SpringBootTest
|
|
|
+@WebAppConfiguration
|
|
|
+@AutoConfigureMockMvc
|
|
|
+public class TestBase {
|
|
|
+ @Autowired
|
|
|
+ protected MockMvc mockMvc;
|
|
|
+
|
|
|
+ @Before
|
|
|
+ public void init() {
|
|
|
+ System.out.println("开始测试-----------------");
|
|
|
+ }
|
|
|
+
|
|
|
+ @After
|
|
|
+ public void after() {
|
|
|
+ System.out.println("测试结束-----------------");
|
|
|
+ }
|
|
|
+}
|