Use when you need to review, improve, or write Java unit tests — including migrating from JUnit 4 to JUnit 5, adopting AssertJ for fluent assertions, structuring tests with Given-When-Then, ensuring test independence, applying parameterized tests, mocking dependencies with Mockito, verifying boundary conditions (RIGHT-BICEP, CORRECT, A-TRIP), leveraging JSpecify null-safety annotations, or eliminating testing anti-patterns such as reflection-based tests or shared mutable state. Part of the skills-for-java project
83
78%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Optimize this skill with Tessl
npx tessl skill review --optimize ./skills/131-java-testing-unit-testing/SKILL.mdReview and improve Java unit tests using modern JUnit 5, AssertJ, and Mockito best practices.
What is covered in this Skill?
@Test, @BeforeEach, @AfterEach, @DisplayName, @Nested, @ParameterizedTestassertThat, assertThatThrownBy@ValueSource/@CsvSource/@MethodSource@Mock, @InjectMocks, MockitoExtensionassertThatThrownBy, exception messages@NullMarked, @NullableScope: The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples.
Before applying any unit test changes, ensure the project compiles. If compilation fails, stop immediately — do not proceed until resolved. After applying improvements, run full verification.
./mvnw compile or mvn compile before applying any change./mvnw clean verify or mvn clean verify after applying improvementsFor detailed guidance, examples, and constraints, see references/131-java-testing-unit-testing.md.
9ec21dd
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.