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

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, and junit-jupiter-params for parameterized tests.
  • Use build tool commands to run tests: mvn test or gradle test.

Test Structure

  • Test classes should have a Test suffix, e.g., CalculatorTest for a Calculator class.
  • Use @Test for test methods.
  • Follow the Arrange-Act-Assert (AAA) pattern.
  • Name tests using a descriptive convention, like methodName_should_expectedBehavior_when_scenario.
  • Use @BeforeEach and @AfterEach for per-test setup and teardown.
  • Use @BeforeAll and @AfterAll for per-class setup and teardown (must be static methods).
Related skills

More from github/awesome-copilot

Installs
9.7K
GitHub Stars
32.8K
First Seen
Feb 25, 2026