Testing

From andresdiegolanda/design-first-ai · View interactive version

Testing is an AI agent skill from the GitHub repository andresdiegolanda/design-first-ai. JUnit and WebMvcTest patterns for the Spring MVC demo. Use when writing any new test or adding coverage.

How to use this skill

Skill file

Skill: Testing (spring-mvc-demo)

Service tests (plain JUnit, no Spring)

class ProductServiceTest {
    private ProductService service;

    @BeforeEach
    void setUp() {
        service = new ProductService();  // fresh store per test
    }
}

Controller tests (`@WebMvcTest`)

@WebMvcTest(ProductController.class)
class ProductControllerTest {
    @Autowired MockMvc mockMvc;
    @Autowired ObjectMapper objectMapper;
    @MockBean ProductService productService;
}

Rules

Test naming

method_condition_expectedResult

Design Constraints

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.