321-frameworks-spring-boot-testing-unit-tests — скилл
Скилл ведёт агента по юнит-тестам Spring Boot: Mockito без поднятия контекста, срезы для контроллеров, параметризованные тесты. Пригодится, когда в проекте расплодились @SpringBootTest.
npx skills add jabrena/plinth --skill 321-frameworks-spring-boot-testing-unit-tests -a claude-codeЧто делает 321-frameworks-spring-boot-testing-unit-tests
Скилл описывает, как писать юнит-тесты Spring Boot с Mockito. Чистые тесты для @Service и @Component строятся на @ExtendWith(MockitoExtension.class), @Mock и @InjectMocks — без запуска Spring-контекста. Для контроллеров берутся срезы @WebMvcTest с @MockitoBean, для сериализации — @JsonTest с проверкой значений через extractingJsonPathStringValue.
Внутри — правила и примеры хорошего и плохого кода, включая параметризованные тесты через @CsvSource и @MethodSource вместо копипасты методов, @TestConfiguration, @ActiveProfiles и фиксированные clock-бины для предсказуемой настройки. Отдельно оговорена современная API моков: @MockitoBean и @MockitoSpyBean, тогда как @MockBean и @SpyBean в Boot 4.0.x удалены.
Скилл требует, чтобы проект компилировался до правок: сначала ./mvnw compile или mvn compile, при ошибке работа останавливается, а после изменений прогоняется ./mvnw clean verify. Если область задачи размыта или не хватает файлов и инструментов, агент должен остановиться и спросить. Для интеграционных тестов есть отдельный скилл @322-frameworks-spring-boot-testing-integration-tests, для Java без привязки к фреймворку — @131-java-testing-unit-testing.
Какие задачи решает
- написать Mockito-тесты для сервиса без поднятия Spring-контекста
- заменить
@SpringBootTestна срез@WebMvcTestдля контроллера - свести повторяющиеся тест-методы в один параметризованный
- проверить JSON-сериализацию через
@JsonTest - перевести тесты с удалённого
@MockBeanна@MockitoBean
Примеры запросов агенту
- Напиши юнит-тесты для этого
@Serviceчерез Mockito, без Spring-контекста - Замени
@SpringBootTestна@WebMvcTestс@MockitoBeanв тестах контроллера - Перепиши эти три похожих теста в один
@ParameterizedTestс@CsvSource
Как установить 321-frameworks-spring-boot-testing-unit-tests
1Через Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 321-frameworks-spring-boot-testing-unit-tests -a claude-code2Вручную: положить файлы
~/.claude/skills/321-frameworks-spring-boot-testing-unit-tests/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/321-frameworks-spring-boot-testing-unit-tests/
1Через Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 321-frameworks-spring-boot-testing-unit-tests -a codex2Вручную: положить файлы
.agents/skills/321-frameworks-spring-boot-testing-unit-tests/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 321-frameworks-spring-boot-testing-unit-tests -a cursor2Вручную: положить файлы
.cursor/skills/321-frameworks-spring-boot-testing-unit-tests/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install jabrena/plinth 321-frameworks-spring-boot-testing-unit-tests2Вручную: положить файлы
.github/skills/321-frameworks-spring-boot-testing-unit-tests/SKILL.md1Через Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 321-frameworks-spring-boot-testing-unit-tests -a gemini-cli2Командой платформы
gemini skills install https://github.com/jabrena/plinth --path skills/321-frameworks-spring-boot-testing-unit-testsВручную: положить файлы
.devin/skills/321-frameworks-spring-boot-testing-unit-tests/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 321-frameworks-spring-boot-testing-unit-tests -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о 321-frameworks-spring-boot-testing-unit-tests
Как установить 321-frameworks-spring-boot-testing-unit-tests в Claude?
Выполните npx skills add jabrena/plinth --skill 321-frameworks-spring-boot-testing-unit-tests -a claude-code. Скилл окажется в ~/.claude/skills/321-frameworks-spring-boot-testing-unit-tests/SKILL.md.
Что делает этот скилл?
Задаёт агенту правила юнит-тестирования Spring Boot с Mockito: чистые тесты для сервисов, срезы для контроллеров, @JsonTest, параметризованные тесты и настройку через @TestConfiguration.
Чем он отличается от скиллов по интеграционным тестам и Java?
Этот скилл про юнит-тесты Spring Boot. Для интеграционных тестов есть @322-frameworks-spring-boot-testing-integration-tests, для Java без привязки к фреймворку — @131-java-testing-unit-testing.
Исходный текст
SKILL.md · Apache-2.0
--- name: 321-frameworks-spring-boot-testing-unit-tests description: Use when you need to write unit tests for Spring Boot applications — including pure unit tests with @ExtendWith(MockitoExtension.class) for @Service/@Component, slice tests with @WebMvcTest and @MockitoBean for controllers, @JsonTest for JSON serialization, parameterized tests with @CsvSource/@MethodSource, test profiles, and @TestConfiguration. For framework-agnostic Java use @131-java-testing-unit-testing. For integration tests use @322-frameworks-spring-boot-testing-integration-tests. This should trigger for requests such as Review Java code for Spring Boot unit tests; Apply best practices for Spring Boot unit tests in Java code; Write Mockito-first unit tests for Spring Boot services; Avoid unnecessary @SpringBootTest in Spring unit tests; Review Spring Boot slice-free unit test design. Part of Plinth Toolkit license: Apache-2.0 metadata: author: Juan Antonio Breña Moral version: 0.19.0 --- # Spring Boot Unit Testing with Mockito Apply Spring Boot unit testing guidelines with Mockito. **What is covered in this Skill?** - Pure unit tests: @ExtendWith(MockitoExtension.class), @Mock, @InjectMocks for @Service/@Component (no Spring context) - Slice tests: @WebMvcTest, @MockitoBean for controllers (Spring Boot 4.0.x — @MockBean removed) - @JsonTest for JSON serialization with correct JSON value assertions (extractingJsonPathStringValue, etc.) - Parameterized tests: @ParameterizedTest with @CsvSource or @MethodSource over copy-pasted methods - Java records for domain objects in tests - @TestConfiguration, @ActiveProfiles, @Primary fixed-clock beans for deterministic test setup - Modern mocking API: @MockitoBean / @MockitoSpyBean; @MockBean/@SpyBean are deprecated/removed in Boot 4.0.x **Scope:** Apply recommendations based on the reference rules and good/bad code examples. For integration tests use @322-frameworks-spring-boot-testing-integration-tests. ## Constraints Before applying any test changes, ensure the project compiles. If compilation fails, stop immediately. After applying improvements, run full verification. - **MANDATORY**: Run `./mvnw compile` or `mvn compile` before applying any change - **SAFETY**: If compilation fails, stop immediately - **VERIFY**: Run `./mvnw clean verify` or `mvn clean verify` after applying improvements - **BEFORE APPLYING**: Read the reference for detailed rules and good/bad patterns - **EDGE CASE**: If request scope is ambiguous, stop and ask a clarifying question before applying changes - **EDGE CASE**: If required inputs, files, or tooling are missing, report what is missing and ask whether to proceed with setup guidance ## When to use this skill - Review Java code for Spring Boot unit tests - Apply best practices for Spring Boot unit tests in Java code - Write Mockito-first unit tests for Spring Boot services - Avoid unnecessary @SpringBootTest in Spring unit tests - Review Spring Boot slice-free unit test design ## Workflow 1. **Read reference and assess project context** Read `references/321-frameworks-spring-boot-testing-unit-tests.md` and inspect the current project setup before proposing changes. 2. **Gather scope and decide target improvements** Identify requested outcomes, constraints, and the minimum safe set of changes to apply. 3. **Apply framework-aligned changes** Implement or refactor configuration/code following the reference patterns and project conventions. 4. **Run verification and report results** Execute appropriate build/tests and summarize what changed, what was verified, and any follow-up actions. ## Reference For detailed guidance, examples, and constraints, see [references/321-frameworks-spring-boot-testing-unit-tests.md](references/321-frameworks-spring-boot-testing-unit-tests.md).
© Juan Antonio Breña Moral · Apache-2.0 · jabrena/plinth