backend-spring-test

Reviews Spring Boot 3.x test code for slice selection, mocking, and setup issues.

3|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/infraspecdev/tesseract --skill backend-spring-test
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-spring-test
Source: https://github.com/infraspecdev/tesseract/tree/main/shield/skills/backend/spring-test
Command: npx skills add https://github.com/infraspecdev/tesseract --skill backend-spring-test

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you catch Spring Boot test anti-patterns that make suites slow, fragile, or misleading, especially when the wrong test slice or mock strategy hides real defects.

Core Features & Use Cases

  • Slice Selection Review: Checks whether a test should use Spring Boot integration, MVC, JPA, JSON, or another narrower slice.
  • Mock and Context Hygiene: Flags excessive mocking, misuse of Spring test annotations, and unnecessary full-context bootstrapping.
  • Isolation and Data Strategy: Evaluates context reset behavior, transactional rollback, security context setup, and database choices such as Testcontainers versus H2.
  • Use Case: A team asks why controller tests are slow and brittle; this Skill identifies overused full-context tests and recommends the most appropriate Spring test pattern.

Quick Start

Review the attached Spring Boot test files and recommend the best slice annotation, mocking approach, and isolation strategy for each test.

Frequently Asked Questions about backend-spring-test

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

FAQPage Schema
How do I choose the right Spring Boot test slice for my controller or repository tests?

Spring Boot test slice selection depends on the target layer: use @WebMvcTest for controllers, @DataJpaTest for repositories, and full integration tests only when validating cross-layer interactions. Correct slice selection isolates context and prevents excessive mocking.

Why are my Spring Boot tests slow and brittle with too much mocking?

Slow and brittle Spring Boot tests often stem from overusing full-context bootstrapping and excessive MockBean placement. Replacing broad integration tests with narrower slice annotations improves isolation, reduces context loading overhead, and exposes real defects.

When should I use Testcontainers versus H2 for Spring Boot repository tests?

Testcontainers is recommended for repository tests requiring production-accurate database behavior, while H2 suits faster, lighter execution where dialect differences are acceptable. Evaluating database choices ensures test reliability without sacrificing execution speed or isolation.

How do I fix Spring test annotation misuse and context isolation issues?

Fixing Spring test annotation misuse involves evaluating transactional rollback, security context setup, and mock placement to ensure proper context isolation. Applying correct slice annotations prevents unnecessary full-context bootstrapping and stabilizes fragile test setups.

What are the limitations of using MockBean in Spring Boot 3.x tests?

Using MockBean in Spring Boot 3.x tests can mask integration defects and slow context reloading if applied excessively. Limitations include fragile test setup and misleading results when mocking replaces real component interactions within narrow test slices.

Does this Spring test review support security context and serialization testing scenarios?

Spring test review supports security context and serialization testing scenarios by evaluating slice scope, context reset behavior, and annotation hygiene. It checks whether JSON slices or security-specific setups are applied correctly for robust validation.