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-service-unit-tests.jsonverifiers/

{
  "instruction": "Write unit tests for a Spring Boot payment processing service. PaymentService has methods: processPayment(PaymentRequest request) which validates the amount, calls PaymentGateway.charge(), saves to PaymentRepository, and returns PaymentResult. It throws InsufficientFundsException for amounts over the account balance.",
  "relevant_when": "Agent writes unit tests for a Spring Boot service class",
  "context": "Proactively check that agents use plain Mockito (@Mock + @InjectMocks) for service unit tests instead of starting a Spring context, and use AssertJ for assertions.",
  "sources": [
    {
      "type": "file",
      "filename": "skills/springboot-testing/SKILL.md",
      "tile": "tessl-labs/springboot-testing"
    }
  ],
  "checklist": [
    {
      "name": "no-spring-context",
      "rule": "Agent uses @ExtendWith(MockitoExtension.class) and plain @Mock annotations, NOT @SpringBootTest or @WebMvcTest. Service unit tests should not start a Spring context.",
      "relevant_when": "Agent writes unit tests for a Spring Boot service class"
    },
    {
      "name": "mock-annotation-for-dependencies",
      "rule": "Agent uses @Mock for repository and gateway dependencies (e.g., @Mock PaymentRepository, @Mock PaymentGateway)",
      "relevant_when": "Agent mocks dependencies in service unit tests"
    },
    {
      "name": "injectmocks-for-service",
      "rule": "Agent uses @InjectMocks on the service under test to auto-inject @Mock dependencies",
      "relevant_when": "Agent instantiates the service under test"
    },
    {
      "name": "assertj-assertions",
      "rule": "Agent uses AssertJ assertThat() for assertions instead of JUnit assertEquals/assertTrue",
      "relevant_when": "Agent writes assertions in unit tests"
    },
    {
      "name": "exception-test",
      "rule": "Agent tests exception scenarios using assertThatThrownBy() or assertThrows(), e.g., verifying InsufficientFundsException is thrown for invalid amounts",
      "relevant_when": "Agent tests error handling in service methods"
    },
    {
      "name": "verify-interactions",
      "rule": "Agent uses Mockito verify() to confirm expected interactions with dependencies (e.g., verify(paymentRepository).save(any()) or verify(paymentGateway).charge(any()))",
      "relevant_when": "Agent verifies service interactions with dependencies"
    },
    {
      "name": "happy-path-tested",
      "rule": "Agent includes a test for the successful payment flow: gateway charges, repository saves, correct result returned",
      "relevant_when": "Agent tests the main success path of a service method"
    }
  ]
}

tile.json