springboot-tdd
Skill3 starsChanged 7 months agoMITView on GitHub
Test-driven development patterns for Spring Boot 3.x. Covers JUnit 5, MockMvc, Testcontainers, service mocking with Mockito, slice tests, integration tests, and test configuration management.
We split this skill into the rules it gives an agent
1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.
0
Common
Most of the 14 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Test-driven development workflow for Spring Boot 3.x with JUnit 5.
“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Spring Boot TDD Patterns
Test-driven development workflow for Spring Boot 3.x with JUnit 5.
Test Pyramid
/ E2E \ <- Few, slow, high confidence
/ Integration \ <- Moderate, Testcontainers
/ Slice Tests \ <- Fast, focused (@WebMvcTest, @DataJpaTest)
/ Unit Tests \ <- Many, fastest, isolatedUnit Tests (Service Layer)
@ExtendWith(MockitoExtension.class)
class UserServiceTest {
@Mock
private UserRepository userRepository;
@InjectMocks
private UserServiceImpl userService;
@Test
void findById_existingUser_returnsResponse() {
// Arrange
UUID id = UUID.randomUUID();
User user = User.builder().name("Alice").email("alice@example.com").build();
when(userRepository.findById(id)).thenReturn(Optional.of(user));
// Act
UserResponse result = userService.findById(id);
// Assert
assertThat(result.name()).isEqualTo("Alice");
assertThat(result.email()).isEqualTo("alice@example.com");
verify(userRepository).findById(id);
}
@Test
void findById_nonExistingUser_throwsException() {
UUID id = UUID.randomUUID();
when(userRepository.findById(id)).thenReturn(Optional.empty());
assertThatThrownBy(() -> userService.findById(id))
.isInstanceOf(ResourceNotFoundException.class)
.hasMessageContaining(id.toString());
}
@Test
void create_validRequest_savesAndReturns() {
UserRequest request = new UserRequest("Alice", "alice@example.com");
User saved = User.builder().name("Alice").email("alice@example.com").build();
when(userRepository.save(any(User.class))).thenReturn(saved);
UserResponse result = userService.create(request);
assertThat(result.name()).isEqualTo("Alice");
verify(userRepository).save(argThat(u -> u.getName().equals("Alice")));
}
}Controller Slice Tests (@WebMvcTest)
@WebMvcTest(UserController.class)
@AutoConfigureMockMvc(addFilters = false) // Disable security for unit tests
class UserControllerTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private UserService userService;
@Autowired
private ObjectMapper objectMapper;
@Test
void listUsers_returnsPageOfUsers() throws Exception {
Page<UserResponse> page = new PageImpl<>(List.of(
new UserResponse(UUID.randomUUID(), "Alice", "alice@example.com", true, Instant.now())
));
when(userService.findAll(any(Pageable.class))).thenReturn(page);
mockMvc.perform(get("/api/v1/users"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.content", hasSize(1)))
.andExpect(jsonPath("$.content[0].name").value("Alice"));
}
@Test
void createUser_validRequest_returns201() throws Exception {
UserRequest request = new UserRequest("Alice", "alice@example.com");
UserResponse response = new UserResponse(
UUID.randomUUID(), "Alice", "alice@example.com", true, Instant.now());
when(userService.create(any(UserRequest.class))).thenReturn(response);
mockMvc.perform(post("/api/v1/users")
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(request)))
.andExpect(status().isCreated())
.andExpect(jsonPath("$.name").value("Alice"));
}
@Test
void createUser_invalidEmail_returns400() throws Exception {
String json = """
{"name": "Alice", "email": "not-an-email"}
""";
mockMvc.perform(post("/api/v1/users")
.contentType(MediaType.APPLICATION_JSON)
.content(json))
.andExpect(status().isBadRequest())
.andExpect(jsonPath("$.errors.email").exists());
}
@Test
void getUser_notFound_returns404() throws Exception {
UUID id = UUID.randomUUID();
when(userService.findById(id)).thenThrow(new ResourceNotFoundException("User", id));
mockMvc.perform(get("/api/v1/users/{id}", id))
.andExpect(status().isNotFound());
}
}Repository Slice Tests (@DataJpaTest)
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@Testcontainers
class UserRepositoryTest {
@Container
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16-alpine");
@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", postgres::getJdbcUrl);
registry.add("spring.datasource.username", postgres::getUsername);
registry.add("spring.datasource.password", postgres::getPassword);
}
@Autowired
private UserRepository userRepository;
@Test
void findByEmail_existingEmail_returnsUser() {
User user = User.builder().name("Alice").email("alice@example.com").build();
userRepository.save(user);
Optional<User> found = userRepository.findByEmail("alice@example.com");
assertThat(found).isPresent();
assertThat(found.get().getName()).isEqualTo("Alice");
}
@Test
void findByEmail_nonExistingEmail_returnsEmpty() {
Optional<User> found = userRepository.findByEmail("nobody@example.com");
assertThat(found).isEmpty();
}
@Test
void findAllActive_excludesInactive() {
userRepository.save(User.builder().name("Active").email("a@test.com").active(true).build());
userRepository.save(User.builder().name("Inactive").email("b@test.com").active(false).build());
Page<User> active = userRepository.findAllActive(PageRequest.of(0, 10));
assertThat(active.getContent()).hasSize(1);
assertThat(active.getContent().get(0).getName()).isEqualTo("Active");
}
}Integration Tests
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Testcontainers
@ActiveProfiles("test")
class UserIntegrationTest {
@Container
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16-alpine");
@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", postgres::getJdbcUrl);
registry.add("spring.datasource.username", postgres::getUsername);
registry.add("spring.datasource.password", postgres::getPassword);
}
@Autowired
private TestRestTemplate restTemplate;
@Autowired
private UserRepository userRepository;
@BeforeEach
void setUp() {
userRepository.deleteAll();
}
@Test
void fullCrudLifecycle() {
// Create
UserRequest request = new UserRequest("Alice", "alice@example.com");
ResponseEntity<UserResponse> createResponse = restTemplate.postForEntity(
"/api/v1/users", request, UserResponse.class);
assertThat(createResponse.getStatusCode()).isEqualTo(HttpStatus.CREATED);
UUID userId = createResponse.getBody().id();
// Read
ResponseEntity<UserResponse> getResponse = restTemplate.getForEntity(
"/api/v1/users/{id}", UserResponse.class, userId);
assertThat(getResponse.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(getResponse.getBody().name()).isEqualTo("Alice");
// Update
restTemplate.put("/api/v1/users/{id}", new UserRequest("Bob", "alice@example.com"), userId);
UserResponse updated = restTemplate.getForObject("/api/v1/users/{id}", UserResponse.class, userId);
assertThat(updated.name()).isEqualTo("Bob");
// Delete
restTemplate.delete("/api/v1/users/{id}", userId);
ResponseEntity<Void> deleteCheck = restTemplate.getForEntity(
"/api/v1/users/{id}", Void.class, userId);
assertThat(deleteCheck.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
}Test Configuration
# src/test/resources/application-test.yml
spring:
jpa:
hibernate:
ddl-auto: create-drop
show-sql: true
flyway:
enabled: false # Use Hibernate DDL for tests
logging:
level:
org.hibernate.SQL: DEBUG
org.hibernate.orm.jdbc.bind: TRACETDD Workflow Commands
# Run all tests
./gradlew test
# Run specific test class
./gradlew test --tests "com.example.app.service.UserServiceTest"
# Run with coverage (JaCoCo)
./gradlew test jacocoTestReport
# Run only unit tests
./gradlew test --tests "*Test"
# Run only integration tests
./gradlew test --tests "*IntegrationTest"
# Continuous test runner
./gradlew test --continuousJaCoCo Coverage Config
// build.gradle
plugins {
id 'jacoco'
}
jacocoTestReport {
reports {
html.required = true
xml.required = true
}
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.80 // 80% coverage minimum
}
}
}
}
check.dependsOn jacocoTestCoverageVerificationChecklist
- Unit tests for all service methods with Mockito
- Controller tests with MockMvc for HTTP behavior
- Repository tests with Testcontainers (real database)
- Integration tests covering full request lifecycle
- Validation error cases tested (400 responses)
- Not-found cases tested (404 responses)
- Test profile with separate configuration
- JaCoCo coverage threshold at 80%
- Tests isolated with
@BeforeEachcleanup - Testcontainers for database-dependent tests
Other versions15 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 15
- loulanyue/awesome-claude-notes★ 272same name
- Fmarzochi/EGC★ 61same name
- FaisalAlqarni/sp-ecc★ 9same name
- gongyijie85/dsh-ecc★ 8same name
- Lukasbrujula/claude-code-framework★ 4same name
- gabrielrovesti/ai-agent-skills★ 1same name
- junimnjw/everything-claude-code★ 1same name
- minghaoZhangZ/shipkit★ 1same name
- royaluniondesign-sys/claude-os★ 1same name
- SamuelNDCE/claude-super-skill-library★ 1same name
5 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use configure-ecc, content-hash-cache-pattern and 9 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
royaluniondesign-sysSkillconfigure-ecc
Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.
Also in 5 projects that use this
royaluniondesign-sysSkillcontent-hash-cache-pattern
Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.
Also in 5 projects that use this
junimnjwSkillcarrier-relationship-management
Codified expertise for managing carrier portfolios, negotiating freight rates, tracking carrier performance, allocating freight, and maintaining strategic carrier relationships. Informed by transportation managers with 15+ years experience. Includes scorecarding frameworks, RFP processes, market intelligence, and compliance vetting. Use when managing carriers, negotiating rates, evaluating carrier performance, or building freight strategies.
Also in 4 projects that use this
junimnjwSkillralphinho-rfc-pipeline
RFC-driven multi-agent DAG execution pattern with quality gates, merge queues, and work unit orchestration.
Also in 4 projects that use this
loulanyueSkillsafety-guard
Also in 4 projects that use this
loulanyueSkillnuxt4-patterns
Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.
Also in 3 projects that use this
- +2 more from royaluniondesign-sys
- +3 more from junimnjw
In this repository72 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- api-designerSkill
- backend-patternsSkill
- code-reviewerSkill
- debugging-assistantSkill
- golang-testingSkill
- project-guidelines-exampleSkill
- python-testingSkill
- refactoring-guideSkill
- spec-driven-developmentSkill
- tdd-workflowSkill
- verification-loopSkill
- update-docsSkill
- api-docsSkill
- changelog-writerSkill
- readme-generatorSkill
- django-patternsSkill
- django-securitySkill
- django-tddSkill
- django-verificationSkill
- fastapi-patternsSkill
- nextjs-patternsSkill
- react-patternsSkill
- springboot-patternsSkill
- springboot-securitySkill
- branch-strategySkill
- changelogSkill
- commit-helperSkill
- pr-creatorSkill
- prSkill
- evolveSkill
- instinct-exportSkill
- instinct-importSkill
- instinct-statusSkill
- cleanupSkill
- lint-fixSkill
- refactor-cleanSkill
- update-depsSkill
- continuous-learningSkill
- continuous-learning-v2Skill
- eval-harnessSkill
- iterative-retrievalSkill
- strategic-compactSkill
- golang-patternsSkill
- python-patternsSkill
- rust-patternsSkill
- typescript-patternsSkill
- accessibility-checkerSkill
- build-fixSkill
- code-reviewSkill
- e2eSkill
- performance-reviewerSkill
- security-auditorSkill
- security-reviewSkill
- test-coverageSkill
- checkpointSkill
- deploySkill
- evalSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

