Prompts-MCP 686 skills · ai / design / design-pattern / framework / fundamentals / habit / lang / tech-selection /mcp/sse
framework framework/testing/index.md medium

framework-testing-index

Java 测试约定 — JUnit5 写法 / Mockito 隔离依赖 / Spring Boot 测试分层 / 测试金字塔四个独立决策点。Use when 写单元测试 / mock 外部依赖 / 选 @SpringBootTest 还是 @WebMvcTest / 定测试分层策略时。

子项索引

子项 一句话
testing-junit5-basics skill JUnit5 测试写法 — @Test / @BeforeEach 生命周期、@ParameterizedTest 参数化、assertThrows / assertAll 断言
testing-mockito-stubbing skill Mockito 隔离依赖 — @Mock 造替身、@InjectMocks 注入被测类、when-thenReturn 打桩、verify 校验交互
testing-spring-boot-test skill Spring Boot 测试分层选型 — @SpringBootTest 全容器集成 vs @WebMvcTest 切 controller 层 vs 纯单测不起 Spring
testing-test-pyramid skill 测试金字塔分层比例 — 单元测试最多、集成测试居中、E2E 最少,及常见反模式(测试依赖外部 DB/网络、mock 一切测了个寂寞)

Testing · Java 测试约定索引

四个独立决策点,按你正在做的事下钻:

你在做什么 进哪个
写测试方法、断言、参数化、断言异常 junit5-basics
mock 掉 service/dao 等外部依赖做隔离单测 mockito-stubbing
纠结起不起 Spring 容器、用哪个测试注解 spring-boot-test
规划单测/集成/E2E 的比例、避免测试反模式 test-pyramid

链接