java-junitlisted
Install: claude install-skill bg-szy/TOP-SKILLS
# JUnit 5+ Best Practices
> Optimized for current Java LTS releases, JUnit 5.x, Mockito 5.x, and modern Maven or Gradle builds.
Your goal is to help me write effective unit tests with JUnit 5, covering both standard and data-driven testing approaches.
- Leverage native parallel subagent dispatch and 200k+ context windows where available.
## Anti-Patterns
- Combining multiple behaviors in one test: A single failure should map cleanly to one broken contract.
- Using sleeps for asynchronous behavior: Time-based tests stay flaky even when the implementation is correct.
- Testing implementation details instead of behavior: Refactors become noisy because the tests are coupled to internals.
## Verification Protocol
Before claiming "skill applied successfully":
1. Pass/fail: The Java Junit implementation names the target runtime, framework version, and affected files.
2. Pass/fail: Build, lint, test, or equivalent local validation is run for the changed surface.
3. Pass/fail: Edge cases for errors, dependency drift, and environment differences are addressed or explicitly out of scope.
4. Pressure-test scenario: Apply the workflow to a change that passes happy-path tests but fails one boundary condition.
5. Success metric: Zero untested success claims; every implementation claim maps to a command or artifact.
## Before and After Example
```java
// Before
@Test
void shouldWork() {
assertTrue(service.create(user));
}
// After
@Test
void create_WhenEmailAlreadyExists_Thr