diff --git a/api-web/api-interface/pom.xml b/api-web/api-interface/pom.xml index 5c063d5..c5aeab6 100644 --- a/api-web/api-interface/pom.xml +++ b/api-web/api-interface/pom.xml @@ -24,6 +24,12 @@ 2.3.0 + + org.springframework.boot + spring-boot-starter-test + test + + diff --git a/api-web/api-interface/src/test/java/com/ApiInterfaceApplicationTests.java b/api-web/api-interface/src/test/java/com/ApiInterfaceApplicationTests.java new file mode 100644 index 0000000..7e5321a --- /dev/null +++ b/api-web/api-interface/src/test/java/com/ApiInterfaceApplicationTests.java @@ -0,0 +1,36 @@ +package com; + +import com.heyu.api.ApiUserApiApplication; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +/** + * 集成测试基类 + *

+ * 所有集成测试继承此类,自动加载 Spring 上下文和 dev 环境配置。 + * 子类可直接 @Autowired 注入需要测试的 Service 或 Mapper。 + *

+ * 使用方式: + *

+ * @SpringBootTest(classes = ApiUserApiApplication.class)
+ * class MyServiceTest extends ApiInterfaceApplicationTests {
+ *     @Autowired
+ *     private MyService myService;
+ *
+ *     @Test
+ *     void myTest() {
+ *         // ...
+ *     }
+ * }
+ * 
+ */ +@SpringBootTest(classes = ApiUserApiApplication.class) +@ActiveProfiles("dev") +public class ApiInterfaceApplicationTests { + + @Test + void contextLoads() { + } + +}