test-rest-adapter

Generate and update Kotlin unit tests for Spring REST controllers using @WebMvcTest and MockMvc.

3|Updated Feb 6, 2025
One-click install
npx skills add https://github.com/emaarco/easy-zeebe --skill test-rest-adapter
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-rest-adapter
Source: https://github.com/emaarco/easy-zeebe/tree/main/.claude/skills/test-rest-adapter
Command: npx skills add https://github.com/emaarco/easy-zeebe --skill test-rest-adapter

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill automates the creation and maintenance of unit tests for Spring Boot REST controllers, ensuring code quality and reducing manual testing effort.

Core Features & Use Cases

  • Automated Test Generation: Creates @WebMvcTest using MockMvc and @MockkBean for controller dependencies.
  • Test Fixing: Updates existing controller tests to match controller changes.
  • Use Case: When a new REST endpoint is added to a Spring Boot application, this Skill can automatically generate a comprehensive unit test for it, including request mocking and response assertions.

Quick Start

Use the test-rest-adapter skill to generate tests for the controller file at src/main/kotlin/com/example/controllers/UserController.kt.

Frequently Asked Questions about test-rest-adapter

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

FAQPage Schema
How do I generate unit tests for Spring Boot REST controllers in Kotlin?

This Skill generates unit tests for Spring Boot REST controllers in Kotlin by using @WebMvcTest, MockMvc, and @MockkBean to isolate the web layer and stub use-case dependencies for request mocking and response assertions.

What is the best way to test Spring Boot controller endpoints without starting the full application context?

Testing Spring Boot controller endpoints without the full application context is done using @WebMvcTest, which loads only the web layer and uses MockMvc to verify HTTP request and response behavior.

Can I automatically update existing MockMvc tests when a REST controller changes?

Yes, you can update existing MockMvc tests when a REST controller changes by pointing the generation process to the modified controller file, which adjusts stubbing and verification patterns to match the new logic.

Does this testing approach work with MockkBean for mocking Kotlin dependencies in Spring Boot?

Yes, this testing approach works with MockkBean for mocking Kotlin dependencies in Spring Boot, replacing use-case dependencies in the controller's web layer to isolate and verify controller logic.

How do I fix a Spring Boot controller test when the endpoint logic is updated?

To fix a Spring Boot controller test when endpoint logic is updated, you regenerate the test file to match the current controller implementation, resetting the MockMvc request mocking and @MockkBean stubs.

When should I not use @WebMvcTest for testing REST controllers?

You should not use @WebMvcTest for testing REST controllers when you need to verify integration with real database layers or full application context behavior, as it scopes only to the web layer and mocks dependencies.