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

springboot-test-config.jsonverifiers/

{
  "instruction": "Add test infrastructure to a Spring Boot project that uses PostgreSQL in production. Set up the test configuration so that tests run with an in-memory database, create a test profile, and add a sample integration test for the existing BookController and BookRepository.",
  "relevant_when": "Agent sets up test infrastructure for a Spring Boot project",
  "context": "Proactively check that agents configure test profiles with @ActiveProfiles, use H2 or TestContainers for database isolation, include spring-boot-starter-test, and use @Sql for test data.",
  "sources": [
    {
      "type": "file",
      "filename": "skills/springboot-testing/SKILL.md",
      "tile": "tessl-labs/springboot-testing"
    }
  ],
  "checklist": [
    {
      "name": "starter-test-dependency",
      "rule": "Agent ensures spring-boot-starter-test is included as a test-scoped dependency in pom.xml or build.gradle",
      "relevant_when": "Agent sets up test dependencies for a Spring Boot project"
    },
    {
      "name": "test-profile-config",
      "rule": "Agent creates an application-test.yml (or application-test.properties) in src/test/resources with H2 or embedded database configuration, NOT using the production PostgreSQL URL",
      "relevant_when": "Agent configures test database for a Spring Boot project"
    },
    {
      "name": "activeprofiles-annotation",
      "rule": "Agent uses @ActiveProfiles(\"test\") on test classes to load the test configuration profile",
      "relevant_when": "Agent writes test classes that need test-specific configuration"
    },
    {
      "name": "h2-or-testcontainers",
      "rule": "Agent configures either H2 in-memory database (jdbc:h2:mem:testdb) for fast tests or TestContainers with @ServiceConnection for real PostgreSQL fidelity",
      "relevant_when": "Agent sets up database for Spring Boot tests"
    },
    {
      "name": "correct-slice-annotation",
      "rule": "Agent uses the appropriate test slice: @WebMvcTest for controller tests, @DataJpaTest for repository tests, @SpringBootTest only for integration tests",
      "relevant_when": "Agent creates test classes for different layers"
    },
    {
      "name": "sql-or-data-setup",
      "rule": "Agent uses @Sql annotations with SQL scripts or TestEntityManager or @BeforeEach with repository calls for test data setup, rather than relying on production seed data",
      "relevant_when": "Agent sets up test data for Spring Boot tests"
    },
    {
      "name": "transactional-isolation",
      "rule": "Agent uses @Transactional on integration test classes for automatic rollback, not @DirtiesContext or manual cleanup",
      "relevant_when": "Agent handles test isolation in Spring Boot tests"
    }
  ]
}

tile.json