CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/springboot-testing

Spring Boot testing — @WebMvcTest for controllers, @DataJpaTest for repositories, @SpringBootTest only for integration, MockMvc, @MockBean vs @Mock, AssertJ, @Transactional rollback, @ActiveProfiles, TestContainers

93

1.09x
Quality

89%

Does it follow best practices?

Impact

100%

1.09x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-5/

{
  "context": "Tests whether the agent correctly uses @SpringBootTest for multi-layer integration tests (appropriate here since the flow crosses controller, service, and repository), uses @Transactional for rollback instead of @DirtiesContext, configures a test profile with H2, and uses @ActiveProfiles. The task does not prescribe how to handle test isolation or database config.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "Uses @SpringBootTest",
      "description": "The test class uses @SpringBootTest (correct for integration tests that cross multiple layers). Using @WebMvcTest would be wrong here because we need the full service and repository stack.",
      "max_score": 10
    },
    {
      "name": "Uses @AutoConfigureMockMvc or WebTestClient",
      "description": "The test uses @AutoConfigureMockMvc with MockMvc, or @SpringBootTest(webEnvironment = RANDOM_PORT) with WebTestClient to make HTTP requests.",
      "max_score": 8
    },
    {
      "name": "@Transactional for auto-rollback",
      "description": "The test class is annotated with @Transactional for automatic rollback after each test, instead of manual cleanup or @DirtiesContext. The agent was NOT told how to handle test isolation.",
      "max_score": 12
    },
    {
      "name": "@ActiveProfiles(\"test\")",
      "description": "The test class uses @ActiveProfiles(\"test\") to load the test configuration profile. The agent was NOT told to use profiles.",
      "max_score": 10
    },
    {
      "name": "Test application-test.yml with H2",
      "description": "The agent creates application-test.yml (or application-test.properties) in src/test/resources with H2 in-memory database configuration (jdbc:h2:mem), not pointing at the production PostgreSQL.",
      "max_score": 12
    },
    {
      "name": "Multi-step flow test (create then retrieve)",
      "description": "At least one test creates a user via POST and then retrieves it via GET to verify the full persistence flow.",
      "max_score": 10
    },
    {
      "name": "Duplicate detection test",
      "description": "A test registers a user, then attempts to register with the same email, asserting a 409 Conflict response.",
      "max_score": 8
    },
    {
      "name": "Validation error test",
      "description": "A test sends invalid input and asserts a 400 Bad Request response.",
      "max_score": 8
    },
    {
      "name": "No @DirtiesContext",
      "description": "The test does NOT use @DirtiesContext. @Transactional rollback is the correct approach for database cleanup.",
      "max_score": 8
    },
    {
      "name": "jsonPath or response body assertions",
      "description": "Tests assert on response body content using jsonPath() or deserialization, not just status codes.",
      "max_score": 6
    },
    {
      "name": "H2 driver and ddl-auto in test config",
      "description": "The test configuration includes org.h2.Driver as the driver class and hibernate ddl-auto set to create-drop or create.",
      "max_score": 8
    }
  ]
}

evals

tile.json