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-4/

{
  "context": "Tests whether the agent proactively uses @DataJpaTest for repository tests (not @SpringBootTest), leverages auto-rollback instead of manual cleanup, and uses AssertJ. The task does not specify which test annotation to use or how to manage test data isolation.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "Uses @DataJpaTest not @SpringBootTest",
      "description": "The test class uses @DataJpaTest instead of @SpringBootTest. @DataJpaTest loads only JPA components and auto-configures an embedded database. The agent was NOT told which annotation to use.",
      "max_score": 15
    },
    {
      "name": "Repository autowired",
      "description": "ProductRepository is injected with @Autowired.",
      "max_score": 5
    },
    {
      "name": "TestEntityManager or repository for data setup",
      "description": "Test data is set up using TestEntityManager (persistAndFlush/persist) or the repository itself, not raw SQL or JDBC.",
      "max_score": 10
    },
    {
      "name": "AssertJ assertions",
      "description": "Uses AssertJ assertThat() for assertions (e.g., assertThat(results).hasSize(2), assertThat(results).extracting(...)). Does not use JUnit assertEquals/assertTrue.",
      "max_score": 12
    },
    {
      "name": "No manual cleanup in BeforeEach/AfterEach",
      "description": "The test does NOT manually call deleteAll(), truncate, or similar cleanup in @BeforeEach or @AfterEach. @DataJpaTest is @Transactional by default and auto-rolls back. The agent was NOT told about rollback behavior.",
      "max_score": 12
    },
    {
      "name": "Empty result test included",
      "description": "At least one test verifies that a query returns an empty result when no entities match the criteria.",
      "max_score": 8
    },
    {
      "name": "Custom query methods tested",
      "description": "Tests cover the custom repository methods (findByCategory, findByPriceLessThan, findByInStockTrue), not just basic CRUD.",
      "max_score": 10
    },
    {
      "name": "Meaningful test data",
      "description": "Test data is set up with distinct, realistic values that make test assertions clear (e.g., different categories, different prices, mix of in-stock/out-of-stock).",
      "max_score": 8
    },
    {
      "name": "No @DirtiesContext",
      "description": "The test does not use @DirtiesContext. Repository slice tests auto-rollback and do not need context reset.",
      "max_score": 5
    },
    {
      "name": "No full context loaded",
      "description": "Does not load controllers, services, or other non-JPA beans. The test is purely a data layer slice test.",
      "max_score": 5
    },
    {
      "name": "Save and retrieve round-trip",
      "description": "At least one test saves an entity and then retrieves it to verify persistence works correctly.",
      "max_score": 5
    }
  ]
}

evals

tile.json