spring-junit

Generate JUnit 5 tests for Java 21 Spring Boot banking services, controllers, and repositories.

Updated Feb 25, 2026
One-click install
npx skills add https://github.com/zenobiuszeto/banking-strawman-capabilities --skill spring-junit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spring-junit
Source: https://github.com/zenobiuszeto/banking-strawman-capabilities/tree/main/skills/spring-junit
Command: npx skills add https://github.com/zenobiuszeto/banking-strawman-capabilities --skill spring-junit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a comprehensive, opinionated testing guide and conventions to eliminate flaky tests, poor coverage, and inconsistent test practices in a Java 21 + Spring Boot 3.x banking platform so teams can deliver reliable, production-ready code with clear test responsibilities.

Core Features & Use Cases

  • Layered Testing Guidance: Clear rules for unit tests, controller slices (@WebMvcTest), JPA slices (@DataJpaTest), full integration tests (@SpringBootTest) and architecture tests (ArchUnit).
  • Tooling & Conventions: Prescribes JUnit 5 Jupiter, Mockito 5, AssertJ, MockMvc/WebTestClient, Testcontainers, EmbeddedKafka, JaCoCo 80% coverage gate, and the TestDataFactory pattern.
  • Best Practices: Enforces naming conventions, single-assertion-per-test, BDDMockito given/then style, static Testcontainers usage, exclusion rules for JaCoCo, and use of @Captor for saved-entity verification.
  • Use Case: Use these guidelines to create reliable unit tests for services, slice tests for controllers and repositories, and integration tests that validate Flyway migrations, Kafka consumers, and real database interactions.

Quick Start

Generate JUnit 5 unit and integration tests for AccountService and AccountController using Mockito, AssertJ, @WebMvcTest, and Testcontainers following the naming, TestDataFactory, and single-assertion conventions.

Frequently Asked Questions about spring-junit

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

FAQPage Schema
How do I write JUnit 5 integration tests for a Spring Boot application using Testcontainers?

JUnit 5 integration tests for Spring Boot use @SpringBootTest with static Testcontainers to validate real database interactions and Flyway migrations. Apply AssertJ assertions and TestDataFactory patterns to ensure reliable, production-ready test coverage.

What is the best way to test Spring Boot REST controllers and JPA repositories?

Testing Spring Boot REST controllers and JPA repositories uses @WebMvcTest with MockMvc or WebTestClient for controller slices, and @DataJpaTest for repository slices. Apply Mockito 5 and single-assertion test rules to isolate layer behavior.

How do I enforce architecture rules in a Java Spring Boot application with ArchUnit?

Enforcing architecture rules in Spring Boot uses ArchUnit tests to validate services, repositories, and REST endpoints. This prevents architectural drift by verifying that dependencies and package structures conform to prescribed design constraints.

How do I test Kafka consumers in a Spring Boot integration test environment?

Testing Kafka consumers in Spring Boot integration tests uses @SpringBootTest combined with EmbeddedKafka. This validates message consumption and production behavior in a controlled, embedded messaging environment.

How do I enforce a minimum code coverage gate in Spring Boot using JaCoCo?

Enforcing a minimum code coverage gate in Spring Boot uses JaCoCo configured to an 80% threshold. Apply exclusion rules to bypass specific classes or packages, ensuring coverage metrics reflect meaningful production code testing.

Can I use Mockito 5 and BDDMockito for Spring Boot service unit tests?

Mockito 5 and BDDMockito are used for Spring Boot service unit tests by applying the given/then style and @Captor for saved-entity verification. This ensures clear test responsibilities and consistent test practices.