From 676a835f87fa960e73d11c1dd2d1d972a57a5e0e Mon Sep 17 00:00:00 2001 From: HanLong <404402223@qq.com> Date: Sat, 20 Dec 2025 14:14:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:[=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95]?= =?UTF-8?q?=E9=9B=86=E6=88=90pom=EF=BC=8C=E7=AE=80=E5=8D=95=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hxhq-modules/hxhq-system/pom.xml | 6 +++++ .../business/controller/TestControllerTest.java | 29 ++++++++++++++++++++++ .../hxhq/business/service/ITestServiceTest.java | 27 ++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 hxhq-modules/hxhq-system/src/test/java/com/hxhq/business/controller/TestControllerTest.java create mode 100644 hxhq-modules/hxhq-system/src/test/java/com/hxhq/business/service/ITestServiceTest.java 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