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
@ParameterizedTestwith multiple sources:@ValueSource,@MethodSource,@CsvSource,@CsvFileSource, and@EnumSource - Assertion strategies including static
Assertionsmethods, AssertJ fluent syntax, exception testing withassertThrows, and grouped assertions viaassertAll - Test organization with packages,
@Tagfor categorization,@Nestedfor grouping, and Mockito integration for dependency isolation
SKILL.md
JUnit 5+ Best Practices
Your goal is to help me write effective unit tests with JUnit 5, covering both standard and data-driven testing approaches.
Project Setup
- Use a standard Maven or Gradle project structure.
- Place test source code in
src/test/java. - Include dependencies for
junit-jupiter-api,junit-jupiter-engine, andjunit-jupiter-paramsfor parameterized tests. - Use build tool commands to run tests:
mvn testorgradle test.