java-testing

Write JUnit 5, Mockito, and Testcontainers tests for Java applications.

Updated Dec 26, 2025
One-click install
npx skills add https://github.com/jwvdvuurst/CalculatorCollection --skill java-testing-jwvdvuurst
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: java-testing
Source: https://github.com/jwvdvuurst/CalculatorCollection/tree/main/skills/java-testing
Command: npx skills add https://github.com/jwvdvuurst/CalculatorCollection --skill java-testing-jwvdvuurst

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pyyaml, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve? Writing thorough tests for Java applications requires knowing the right patterns across multiple frameworks like JUnit 5, Mockito, AssertJ, and Testcontainers, which slows down developers and leads to inconsistent test quality. ## Core Features & Use Cases - Unit Testing with JUnit 5 and Mockito: Create tests using @Mock, @InjectMocks, parameterized tests, and BDD-style stubbing with fluent AssertJ assertions. - Integration Testing: Build Spring Boot integration tests with @SpringBootTest slices, MockMvc for API testing, and Testcontainers for real database testing. - TDD Patterns and Coverage: Apply test data builders, JaCoCo coverage thresholds, and a troubleshooting checklist for common test failures. - Use Case: When adding a new service to a Spring Boot application, use this Skill to generate a complete test suite covering unit tests with mocked repositories, controller tests with MockMvc, and repository tests against a PostgreSQL Testcontainer. ## Quick Start Ask the AI to write unit and integration tests for your Java service class using JUnit 5, Mockito, and Testcontainers.

Frequently Asked Questions about java-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write unit tests with JUnit 5 and Mockito?

Annotate the test class with @ExtendWith(MockitoExtension.class), declare dependencies with @Mock, and inject them with @InjectMocks. Stub calls using given/willReturn and verify interactions with then(mock).should().

How to write integration tests with Testcontainers and Spring Boot?

Annotate the test with @Testcontainers and @SpringBootTest, declare a static PostgreSQLContainer with @Container, and register its JDBC URL via @DynamicPropertySource. The container starts automatically and provides a real database for repository tests.

What is the difference between @WebMvcTest and @SpringBootTest?

@WebMvcTest loads only the web layer with MockMvc and requires @MockBean for services, making it fast for controller tests. @SpringBootTest loads the full application context, suiting end-to-end integration scenarios.

Why is my Mockito mock returning null in tests?

Null returns usually mean a missing @ExtendWith(MockitoExtension.class) or a stubbing that does not match the actual invocation arguments. Verify the mock setup matches the called method signature and check @InjectMocks wiring.

How do I enforce test coverage thresholds with JaCoCo?

Add a JaCoCo rule in the Maven plugin configuration setting a COVEREDRATIO limit, such as 0.80 minimum line coverage per bundle. The build fails when coverage drops below the configured threshold.