Spring Boot testing — @WebMvcTest for controllers, @DataJpaTest for repositories, @SpringBootTest only for integration, MockMvc, @MockBean vs @Mock, AssertJ, @Transactional rollback, @ActiveProfiles, TestContainers
93
89%
Does it follow best practices?
Impact
100%
1.09xAverage score across 5 eval scenarios
Passed
No known issues
{
"instruction": "Write integration tests for a Spring Boot user registration flow. The API has: POST /api/users/register (accepts username, email, password; creates user), GET /api/users/{id} (returns user profile), POST /api/users/login (authenticates user). The service persists to a database via UserRepository.",
"relevant_when": "Agent writes end-to-end integration tests for a Spring Boot application",
"context": "Proactively check that agents use @SpringBootTest with @AutoConfigureMockMvc for integration tests, use @Transactional for auto-rollback, use @ActiveProfiles for test configuration, and test across multiple layers.",
"sources": [
{
"type": "file",
"filename": "skills/springboot-testing/SKILL.md",
"tile": "tessl-labs/springboot-testing"
}
],
"checklist": [
{
"name": "springboottest-annotation",
"rule": "Agent uses @SpringBootTest on the test class (appropriate because this is a multi-layer integration test that exercises controller, service, and repository together)",
"relevant_when": "Agent writes integration tests that span multiple Spring Boot layers"
},
{
"name": "autoconfigure-mockmvc",
"rule": "Agent uses @AutoConfigureMockMvc to inject MockMvc, OR uses WebTestClient with webEnvironment = RANDOM_PORT",
"relevant_when": "Agent writes integration tests that make HTTP requests"
},
{
"name": "transactional-rollback",
"rule": "Agent uses @Transactional on the test class for automatic rollback after each test, instead of manual cleanup with deleteAll() or @DirtiesContext",
"relevant_when": "Agent writes integration tests that modify the database"
},
{
"name": "active-profiles-test",
"rule": "Agent uses @ActiveProfiles(\"test\") to load test-specific configuration (e.g., H2 in-memory database instead of production database)",
"relevant_when": "Agent configures test environment for Spring Boot integration tests"
},
{
"name": "multi-step-flow-tested",
"rule": "Agent tests a multi-step flow: creates a resource via POST, then retrieves it via GET to verify persistence across the full stack",
"relevant_when": "Agent writes integration tests for CRUD operations"
},
{
"name": "no-dirtiescontext",
"rule": "Agent does NOT use @DirtiesContext for test isolation. @Transactional auto-rollback is the correct approach for database cleanup between tests.",
"relevant_when": "Agent handles test isolation in Spring Boot integration tests"
},
{
"name": "validation-integration-tested",
"rule": "Agent tests that validation works end-to-end (e.g., duplicate email returns 409 Conflict, or invalid input returns 400 with error details)",
"relevant_when": "Agent writes integration tests for endpoints with business validation"
}
]
}