java-junit

Installation
Summary

JUnit 5 best practices for standard and data-driven unit testing with practical patterns.

  • Covers test structure using Arrange-Act-Assert pattern, lifecycle annotations (@BeforeEach, @AfterEach, @BeforeAll, @AfterAll), and naming conventions with @DisplayName
  • Parameterized testing via @ParameterizedTest with multiple sources: @ValueSource, @MethodSource, @CsvSource, @CsvFileSource, and @EnumSource
  • Assertion strategies including static Assertions methods, AssertJ fluent syntax, exception testing with assertThrows, and grouped assertions via assertAll
  • Test organization with packages, @Tag for categorization, @Nested for grouping, and Mockito integration for dependency isolation
SKILL.md

Java Testing with JUnit 5/6, AssertJ and Mockito

Framework-neutral guidance for fast, deterministic unit tests. For Spring slices use spring-boot-testing (if installed); for real databases/brokers in Docker use java-testcontainers; for failures you cannot explain, java-debugging.

First: detect, don't impose

  1. Read pom.xml/build.gradle*: JUnit version (junit-jupiter, junit-bom, or inherited from a Spring Boot BOM), assertion library, Mockito, Surefire/Failsafe versions, Java release.
  2. Copy the conventions already in src/test/java (naming, assertion library, static imports, mocking style). Do not introduce AssertJ, Mockito or JaCoCo into a project that lacks them without asking.
  3. Never bump the JUnit major version implicitly; upgrading is its own task (see java-upgrade if installed).

JUnit 5 vs JUnit 6

Installs
11.7K
GitHub Stars
40.6K
First Seen
Feb 25, 2026