diff --git a/hxhq-modules/hxhq-system/pom.xml b/hxhq-modules/hxhq-system/pom.xml index 234871a..24218da 100644 --- a/hxhq-modules/hxhq-system/pom.xml +++ b/hxhq-modules/hxhq-system/pom.xml @@ -71,6 +71,12 @@ hxhq-common-swagger + + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/hxhq-modules/hxhq-system/src/test/java/com/hxhq/business/controller/TestControllerTest.java b/hxhq-modules/hxhq-system/src/test/java/com/hxhq/business/controller/TestControllerTest.java new file mode 100644 index 0000000..2e22bfd --- /dev/null +++ b/hxhq-modules/hxhq-system/src/test/java/com/hxhq/business/controller/TestControllerTest.java @@ -0,0 +1,29 @@ +package com.hxhq.business.controller; + +import com.hxhq.system.HxhqSystemApplication; +import org.junit.jupiter.api.Test; +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.mock.web.MockHttpServletResponse; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import static org.junit.jupiter.api.Assertions.*; + +@AutoConfigureMockMvc +@SpringBootTest(classes = HxhqSystemApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class TestControllerTest { + + @Autowired + private MockMvc mvc; + + @Test + public void testGet() throws Exception { + ResultActions perform = mvc.perform(MockMvcRequestBuilders.get("/business/test/info?id=1")); + MockHttpServletResponse response = perform.andReturn().getResponse(); + System.out.println(response.getContentAsString()); + } + +} \ No newline at end of file diff --git a/hxhq-modules/hxhq-system/src/test/java/com/hxhq/business/service/ITestServiceTest.java b/hxhq-modules/hxhq-system/src/test/java/com/hxhq/business/service/ITestServiceTest.java new file mode 100644 index 0000000..19aab71 --- /dev/null +++ b/hxhq-modules/hxhq-system/src/test/java/com/hxhq/business/service/ITestServiceTest.java @@ -0,0 +1,27 @@ +package com.hxhq.business.service; + +import com.hxhq.system.HxhqSystemApplication; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +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.util.Assert; + +import java.util.List; + + +@SpringBootTest(classes = HxhqSystemApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class ITestServiceTest { + + + @Autowired + private ITestService testService; + + @Test + public void test() { + List list = testService.list(); + Assertions.assertEquals(20, list.size(), "数量错误"); + } +} \ No newline at end of file