jabrena avatar

131 Java Testing Unit Testing

This is a comprehensive testing modernizer for Java projects. It walks you through migrating from JUnit 4 to JUnit 5, switching to AssertJ's fluent assertions, and applying proper test structure with Given-When-Then. What's useful here is the safety-first approach: it forces you to compile before making changes and verify afterward, which prevents breaking your build mid-refactor. The skill covers the full testing stack including Mockito mocking, parameterized tests, and boundary condition verification using RIGHT-BICEP and CORRECT principles. It's built for teams trying to eliminate common anti-patterns like reflection-based tests and shared mutable state while adopting modern practices like JSpecify null-safety annotations.

skills.sh installs
134
GitHub stars
393
last updated
Jun 3, 2026

Install

$ npx -y skills add jabrena/cursor-rules-java --skill 131-java-testing-unit-testing --agent claude-code

Installs into .claude/skills of the current project.

Files

Java Unit testing guidelines

Review and improve Java unit tests using modern JUnit 5, AssertJ, and Mockito best practices.

What is covered in this Skill?

  • JUnit 5 annotations: @Test, @BeforeEach, @AfterEach, @DisplayName, @Nested, @ParameterizedTest
  • AssertJ fluent assertions: assertThat, assertThatThrownBy
  • Given-When-Then test structure, descriptive test naming, single-responsibility tests
  • Test independence and isolated state
  • Parameterized tests: @ValueSource/@CsvSource/@MethodSource
  • Mockito dependency mocking: @Mock, @InjectMocks, MockitoExtension
  • Code coverage guidance (JaCoCo), package-private test visibility
  • Testing anti-patterns: reflection, shared state, hard-coded values, testing implementation details
  • Error handling: assertThatThrownBy, exception messages
  • JSpecify null-safety: @NullMarked, @Nullable
  • RIGHT-BICEP coverage principles, A-TRIP test quality, CORRECT boundary condition verification

Scope: The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples.

Constraints

Sponsors

Details

Repository
github.com/jabrena/cursor-rules-java
Categories
Testing & QA, Java & JVM
First seen
Jun 3, 2026

More from jabrena/cursor-rules-java

All 16
1erichowens avatarplaywright-screenshot-inspectorerichowens/some_claude_skillsplaywright screenshot inspector132skills.sh installs
2sickn33 avatarburp-suite-testingsickn33/antigravity-awesome-skillsburp suite testing132skills.sh installs
3absolutelyskilled avatarload-testingabsolutelyskilled/absolutelyskilledload testing127skills.sh installs
40xbigboss avatare2e0xbigboss/claude-codee2e126skills.sh installs
5cinience avataralicloud-ai-audio-cosyvoice-voice-clone-testcinience/alicloud-skillsMinimal CosyVoice voice clone smoke test for Model Studio voice-enrollment.122skills.sh installs
6cinience avataralicloud-ai-audio-cosyvoice-voice-design-testcinience/alicloud-skillsMinimal CosyVoice voice design smoke test for Model Studio voice-enrollment.121skills.sh installs