Testing 178 installs

JUnit 5+ Best Practices

by github/awesome-copilot

Get best practices for JUnit 5 unit testing, including data-driven tests

Skill content

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

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