spring-tdd-mockito

Automates Spring Boot unit testing with Mockito and JUnit 5 templates.

6|1|Updated Dec 26, 2025
One-click install
npx skills add https://github.com/mduongvandinh/skills-java-spring --skill spring-tdd-mockito
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spring-tdd-mockito
Source: https://github.com/mduongvandinh/skills-java-spring/tree/main/java-spring-skills/skills/core/spring-tdd-mockito
Command: npx skills add https://github.com/mduongvandinh/skills-java-spring --skill spring-tdd-mockito

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps developers ensure Spring Boot code quality by applying Test-Driven Development with Mockito, enabling writing tests first and validating design before implementation.

Core Features & Use Cases

  • TDD workflow guidance: Red-Green-Refactor cycle for Spring Boot components.
  • Mockito integration: Annotations like @Mock, @InjectMocks, @Spy, and @Captor for clean test setup.
  • Test skeleton templates: Ready-to-use JUnit 5 test classes for services, controllers, and repositories.

Quick Start

Use this skill to scaffold and run a basic Mockito-based unit test in a Spring Boot project. Example prompt: "Create a Spring Boot unit test for ServiceX that mocks RepositoryY and asserts expected interactions."

Frequently Asked Questions about spring-tdd-mockito

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

FAQPage Schema
How do I write Spring Boot unit tests using Mockito and JUnit 5?

Spring Boot unit testing with Mockito uses annotations like @Mock, @InjectMocks, and @Captor within JUnit 5 test classes. This skill provides ready-to-use test skeleton templates for services, controllers, and repositories to isolate and validate components quickly.

What is the TDD Red-Green-Refactor cycle for Spring Boot components?

The TDD Red-Green-Refactor cycle is a test-driven development workflow guiding you to write failing tests first, implement code to pass them, and then refactor. This skill applies that cycle to Spring Boot services, controllers, and repositories using Mockito.

Can I use Mockito @Spy annotations to test Spring Boot controllers and services?

Yes, Mockito @Spy annotations along with @Mock and @InjectMocks set up clean test environments for Spring Boot controllers and services. The skill integrates these annotations to facilitate isolated testing and verify interactions.

Do I need a running database to run Spring Boot Mockito unit tests?

Spring Boot Mockito unit tests do not need a running database because mocking isolates tested components from external dependencies like repositories. This enables fast feedback by validating service and controller logic without database setup.

What's the best way to mock a Spring Boot repository and assert interactions in a unit test?

Mocking a Spring Boot repository involves using @Mock to simulate the repository and @Captor to capture arguments for verifying interactions. This skill scaffolds these JUnit 5 tests to assert expected behaviors without real database access.