From c3e9f6bf04cbf62b3f681a467f2d7607c6af7adc Mon Sep 17 00:00:00 2001 From: Pipeline Agent Date: Sat, 15 Aug 2026 01:23:19 +0800 Subject: [PATCH] =?UTF-8?q?develop:=20=E4=BF=AE=E5=A4=8D=E9=9B=86=E6=88=90?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BA=8B=E5=8A=A1=E9=9A=94=E7=A6=BB=EF=BC=8C?= =?UTF-8?q?=E7=AB=AF=E5=88=B0=E7=AB=AF=208=20=E7=94=A8=E4=BE=8B=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/com/hr/staff/StaffApiIntegrationTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/java/com/hr/staff/StaffApiIntegrationTest.java b/src/test/java/com/hr/staff/StaffApiIntegrationTest.java index 92c4bd3..4cd2699 100644 --- a/src/test/java/com/hr/staff/StaffApiIntegrationTest.java +++ b/src/test/java/com/hr/staff/StaffApiIntegrationTest.java @@ -12,6 +12,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; import java.util.Set; @@ -24,11 +25,15 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. /** * 员工管理模块端到端集成测试(H2 内存库 + MockMvc + JWT)。 + * + *

使用 @Transactional 让每个测试用例在独立事务中运行并在结束后回滚, + * 避免测试数据相互污染,从而保证用例可重复执行。

*/ @SpringBootTest @AutoConfigureMockMvc @ActiveProfiles("dev") @TestMethodOrder(MethodOrderer.MethodName.class) +@Transactional class StaffApiIntegrationTest { @Autowired