$npx skillfedfor your agent

junit-5-skill

This skill equips you to write robust JUnit 5 tests in Java, from basic assertions and exception handling to parameterized test cases and Mockito-driven mocking. It covers lifecycle management, nested test organization, and anti-patterns to avoid, with quick reference commands for Maven and Gradle execution.

junit-5-skill generates production-grade JUnit 5 tests with assertions, parameterized tests, and Mockito mocking in Java.

AI-generated summary based on this skill's SKILL.md

339 68 MITupdated by LambdaTest

Decision gist · record as of 2026-07-24

junit-5-skill generates production-grade JUnit 5 tests with assertions, parameterized tests, and Mockito mocking in Java. This skill equips you to write robust JUnit 5 tests in Java, from basic assertions and exception handling to parameterized test cases and Mockito-driven mocking. It covers lifecycle management, nested test organization, and anti-patterns to avoid, with quick reference commands for Maven and Gradle execution.

manual: git clone https://github.com/LambdaTest/agent-skills → cp -r agent-skills/junit-5-skill ~/.claude/skills/junit-5-skill
junit-5-skill/SKILL.md · version 4562b517

Use it when

  • junit-5-skill covers key JUnit 5 annotations including @Test, @BeforeEach, @AfterEach, @DisplayName, @Nested, and @ParameterizedTest.
  • junit-5-skill shows how to mock dependencies using Mockito by creating mock objects with Mockito.mock().

Verify before relying

Read SKILL.md below before installing (3 files). Open directory: indexed for reading, not audited.

Same gist for agents: .md · .json

Install

LambdaTest/agent-skills/junit-5-skill · repository language: Python

Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How to write JUnit 5 tests in Java?

junit-5-skill teaches you to write JUnit 5 tests by marking test methods with @Test, using assertions like assertEquals and assertThrows, and organizing tests with @BeforeEach and @AfterEach lifecycle hooks. Start with a simple test class, add your test methods, and run via Maven or Gradle. The skill covers both basic unit tests and advanced patterns like parameterized tests and nested test classes for better organization.

What are JUnit 5 annotations and best practices?

junit-5-skill covers key JUnit 5 annotations including @Test, @BeforeEach, @AfterEach, @DisplayName, @Nested, and @ParameterizedTest. Best practices include using descriptive test names, organizing related tests in nested classes, leveraging @DisplayName for readable output, keeping tests focused and independent, and using parameterized tests to reduce duplication. The skill also teaches when to mock versus when to use real objects.

How do I mock dependencies in JUnit with Mockito?

junit-5-skill shows how to mock dependencies using Mockito by creating mock objects with Mockito.mock(), stubbing behavior with when().thenReturn(), and verifying method calls with verify(). You can inject mocks into your test class and configure them to return specific values or throw exceptions. The skill demonstrates common patterns like mocking external services, verifying interactions, and using argument matchers for flexible assertions.

What are parameterized tests and how do I create them?

junit-5-skill explains parameterized tests as a way to run the same test logic with multiple input sets, reducing code duplication. Use @ParameterizedTest with sources like @ValueSource, @CsvSource, or @MethodSource to provide test data. For example, @CsvSource lets you inline multiple test cases as CSV rows. This approach makes it easy to test edge cases and boundary conditions without writing separate test methods for each scenario.

How do I organize tests with nested classes and lifecycle?

junit-5-skill teaches test organization using @Nested to group related tests into inner classes, improving readability and maintainability. Combine this with lifecycle hooks: @BeforeEach runs before each test, @BeforeAll runs once before all tests in a class, and @AfterEach/@AfterAll clean up afterward. Nested classes inherit parent lifecycle hooks, allowing you to set up shared context and keep tests logically grouped by feature or scenario.

What assertions and exception testing does JUnit 5 provide?

junit-5-skill covers JUnit 5 assertions including assertEquals, assertTrue, assertFalse, assertNull, assertThrows, and assertAll. Use assertThrows to verify that code throws an expected exception with a specific message. Use assertAll to group multiple assertions so all run even if one fails, giving you complete feedback. The skill also shows how to use custom assertion messages and lambda expressions for more expressive, maintainable tests.

SKILL.md

Rendered from the published skill. Quoted content, verbatim.

JUnit 5 Testing Skill

You are a senior Java developer specializing in JUnit 5 testing.

Step 1 — Test Type

├─ "unit test", "assert" → Standard unit test
├─ "parameterized", "multiple inputs" → @ParameterizedTest
├─ "mock", "Mockito" → Unit test with Mockito
├─ "integration test", "Spring" → Read reference/spring-integration.md
└─ Default → Standard unit test

Core Patterns

Basic Test

```java import org.junit.jupiter.api.; import static org.junit.jupiter.api.Assertions.;

class CalculatorTest { private Calculator calculator;

@BeforeEach
void setUp() {
    calculator = new Calculator();
}

@Test
@DisplayName("Addition of two positive

(truncated - see the full file via the links below)

File tree — 3 files
junit-5-skill/SKILL.md
junit-5-skill/reference/advanced-patterns.md
junit-5-skill/reference/playbook.md

Let your AI agent find skills like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.

wish › “Generate production-grade JUnit 5 unit tests with assertions and mocking”

Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →

Related skills

unit-test-service-layer
by giuseppe-trisciuoglio · giuseppe-trisciuoglio/developer-kit

Master isolated service layer testing using Mockito to mock repositories and external clients without database or API calls. This skill teaches you to arrange test data, verify method interactions, and handle exception scenarios with AssertJ assertions.

MITupdated Jun 2026
★ 311repo stars
unit-test-application-events
by giuseppe-trisciuoglio · giuseppe-trisciuoglio/developer-kit

This skill teaches patterns for unit testing Spring ApplicationEvent publishers and @EventListener consumers using JUnit 5 and Mockito, without booting the full Spring context. Learn to mock ApplicationEventPublisher, capture events with ArgumentCaptor, verify listener side effects, and test async event handling. Covers error scenarios and best practices for keeping event tests isolated and deterministic.

MITupdated Jun 2026
★ 311repo stars
Java Test Generator
by dawiddutoit · dawiddutoit/custom-claude

Automatically generate well-structured JUnit 5 test cases for Java classes, complete with Mockito mocking, parameterized test scenarios, and edge case handling. The skill follows Arrange-Act-Assert patterns, creates tests for exception handling, verifies mock interactions, and targets high test coverage across service layers and Spring Boot components.

no license declared → metadata onlyupdated Jan 2026
★ 1repo stars
mocha-skill
by LambdaTest · LambdaTest/agent-skills

mocha-skill enables you to create well-organized unit tests leveraging Mocha's hierarchical test structure and Chai's expressive assertion library. Build comprehensive test suites with clear describe blocks and individual test cases, then execute them to validate your code's behavior.

MITupdated Jul 2026
★ 339repo stars
test-quality
by decebals · decebals/claude-code-java

Test Quality guides you through writing maintainable Java tests using JUnit 5 and AssertJ. It covers the Arrange-Act-Assert pattern, collection and exception assertions, nested test organization, and parameterized testing to improve code coverage and test readability.

MITfor claude-codeupdated Feb 2026
★ 693repo stars
testing
by josavicentevw · josavicentevw/ai-agent-skills

Testing guides you through designing effective test suites, writing unit and integration tests, and applying test-driven development practices. It covers test strategy, the AAA pattern, test fixtures, mocking dependencies, and framework-specific approaches for React, Angular, Python, Java, and Kotlin.

MITupdated Feb 2026
★ 1repo stars

More skills phpunit-skill (MIT) · Java Testing (NOASSERTION) · webapp-selenium-testing (MIT) · unit-test-boundary-conditions (MIT) · pytest-skill (MIT)

Tags
test-automationassertion-librarymock-frameworktest-organizationjava-testingtdd-patternsci-cd-readyparameterization