Claude Code Plugins

Community-maintained marketplace

Feedback

java-spring-testing

@edlovesjava/claudeplus
0
0

Run Java/Spring Boot tests and debug failures. Use when fixing backend tests, implementing new features with tests, or debugging test failures.

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

name java-spring-testing
description Run Java/Spring Boot tests and debug failures. Use when fixing backend tests, implementing new features with tests, or debugging test failures.
allowed-tools Bash, Read, Edit, Grep

Java Spring Boot Testing

Test Execution

Run tests with:

cd /workspaces/claudeplus
./gradlew backend:test                           # All tests
./gradlew backend:test --tests "*TaskControllerTest*"  # Specific test class
./gradlew backend:test --tests "*TaskControllerTest.testMethod*"  # Specific method

Testing Patterns

This project uses JUnit 5 with Mockito and Spring's @WebMvcTest:

Controller Test Structure

@WebMvcTest(TaskController.class)
class TaskControllerTest {
    @Autowired
    private MockMvc mockMvc;

    @MockBean
    private TaskService taskService;

    @Test
    void shouldReturnAllTasks() throws Exception {
        when(taskService.findAll()).thenReturn(List.of(task));

        mockMvc.perform(get("/api/tasks"))
            .andExpect(status().isOk())
            .andExpect(jsonPath("$[0].title").value("Task 1"));
    }
}

Mockito Patterns

  • when(mock.method()).thenReturn(value) - Stub return values
  • verify(mock).method() - Verify interactions
  • @MockBean - Create Spring-managed mock
  • ArgumentCaptor<T> - Capture arguments for assertions

Common Test Fixes

  1. 404 Not Found: Check endpoint path matches controller mapping
  2. Mock not returning: Ensure when() matches exact method signature
  3. JSON parsing errors: Verify @RequestBody and content type headers
  4. CORS issues: Check @CrossOrigin annotation on controller

Test Location

Tests are in: /backend/src/test/java/com/claudeplus/demo/