develop: 修复集成测试事务隔离,端到端 8 用例全部通过
This commit is contained in:
parent
4e22f6faa7
commit
c3e9f6bf04
@ -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)。
|
||||
*
|
||||
* <p>使用 @Transactional 让每个测试用例在独立事务中运行并在结束后回滚,
|
||||
* 避免测试数据相互污染,从而保证用例可重复执行。</p>
|
||||
*/
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("dev")
|
||||
@TestMethodOrder(MethodOrderer.MethodName.class)
|
||||
@Transactional
|
||||
class StaffApiIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user