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

Evaluation results

100%

16%

Bookstore Test Infrastructure

Criteria
Without context
With context

@WebMvcTest for controller test

100%

100%

@DataJpaTest for repository test

100%

100%

@SpringBootTest for integration test

100%

100%

@MockBean in controller test

100%

100%

application-test.yml with H2

100%

100%

@ActiveProfiles("test") on integration test

100%

100%

@Transactional on integration test

0%

100%

AssertJ assertions used

87%

100%

No @DirtiesContext anywhere

100%

100%

No manual deleteAll cleanup

0%

100%

MockMvc in controller test

100%

100%

Multiple meaningful tests per file

100%

100%

spring-boot-starter-test dependency mentioned or assumed

80%

100%

100%

1%

Order Controller Tests

Criteria
Without context
With context

Uses @WebMvcTest not @SpringBootTest

100%

100%

@MockBean for OrderService

100%

100%

MockMvc autowired and used

100%

100%

Mockito when/thenReturn for stubbing

100%

100%

Status code assertions

100%

100%

jsonPath response body assertions

100%

100%

Validation rejection test

100%

100%

Not found test

87%

100%

Content type set on POST

100%

100%

No @DirtiesContext used

100%

100%

AssertJ or proper assertion style

100%

100%

No unnecessary @SpringBootTest or full context

100%

100%

100%

Payment Service Unit Tests

Criteria
Without context
With context

No Spring context loaded

100%

100%

@ExtendWith(MockitoExtension.class)

100%

100%

@Mock for dependencies

100%

100%

@InjectMocks for service under test

100%

100%

AssertJ assertions

100%

100%

Mockito verify for interactions

100%

100%

Exception test for declined payment

100%

100%

Exception test for invalid amount

100%

100%

Happy path test

100%

100%

when/thenReturn for stubbing

100%

100%

No @MockBean used

100%

100%

100%

13%

Product Repository Tests

Criteria
Without context
With context

Uses @DataJpaTest not @SpringBootTest

100%

100%

Repository autowired

100%

100%

TestEntityManager or repository for data setup

100%

100%

AssertJ assertions

100%

100%

No manual cleanup in BeforeEach/AfterEach

0%

100%

Empty result test included

100%

100%

Custom query methods tested

100%

100%

Meaningful test data

100%

100%

No @DirtiesContext

100%

100%

No full context loaded

100%

100%

Save and retrieve round-trip

100%

100%

100%

12%

User Registration Integration Tests

Criteria
Without context
With context

Uses @SpringBootTest

100%

100%

Uses @AutoConfigureMockMvc or WebTestClient

100%

100%

@Transactional for auto-rollback

0%

100%

@ActiveProfiles("test")

100%

100%

Test application-test.yml with H2

100%

100%

Multi-step flow test (create then retrieve)

100%

100%

Duplicate detection test

100%

100%

Validation error test

100%

100%

No @DirtiesContext

100%

100%

jsonPath or response body assertions

100%

100%

H2 driver and ddl-auto in test config

100%

100%

Evaluated
Agent
Claude Code
Model
Claude Sonnet 4.6

Table of Contents