junit-mockito-patterns

Installation
SKILL.md

JUnit5 + Mockito 测试规则

来源:https://junit.org/junit5/docs/current/user-guide/
Mockito:https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html

Capability Boundaries

✅ Strong Suits

  1. JUnit5 迁移规则 — @ExtendWith 替代 @RunWith, @Test 导入 org.junit.jupiter.api
  2. Mockito 规则 — @Mock(外部依赖) + @InjectMocks(被测试对象), 不 Mock POJO
  3. 测试隔离(FIRST原则) — Fast/Independent/Repeatable/Self-Validating/Timely
  4. 切片测试 — @WebMvcTest(Controller) / @DataJpaTest(Repository) / @JsonTest
  5. BDD风格 — BDDMockito.given()/willReturn()/then().should() 替代 when/thenReturn/verify
  6. 行为验证 — verify() + ArgumentCaptor
  7. @ParameterizedTest + @MethodSource — 参数化测试简化多场景
  8. @Nested 分组 — 组织相关测试场景
Installs
31
GitHub Stars
3
First Seen
Jun 22, 2026
junit-mockito-patterns — full-stack-skills/java-skills