
Springboot Tdd
Practice red-green-refactor on Spring Boot features with JUnit 5, Mockito, MockMvc, Testcontainers, and JaCoCo so solo backends hit 80%+ coverage on new endpoints and fixes.
Overview
Spring Boot TDD is an agent skill most often used in Ship (also Build → backend) that guides test-first development with JUnit 5, Mockito, MockMvc, Testcontainers, and JaCoCo for 80%+ coverage.
Install
npx skills add https://github.com/affaan-m/everything-claude-code --skill springboot-tddWhat is this skill?
- Red-green-refactor loop: failing tests first, minimal implementation, then refactor
- Unit tests with JUnit 5 + Mockito (Arrange-Act-Assert, parameterized variants)
- Web layer coverage via @WebMvcTest and MockMvc
- Integration posture with Testcontainers for realistic data dependencies
- JaCoCo coverage target of 80%+ for unit and integration suites
- 80%+ coverage target (unit + integration)
- 4-step workflow: fail → pass → refactor → JaCoCo
Adoption & trust: 5.4k installs on skills.sh; 210k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are adding Spring Boot endpoints or fixes without a disciplined test-first loop, so regressions slip through before you ship.
Who is it for?
Solo Spring Boot API builders who want MockMvc and Testcontainers patterns baked into every feature and bugfix.
Skip if: Non-JVM stacks or teams that forbid writing tests before production code.
When should I use this skill?
Adding Spring Boot features, fixing bugs, refactoring, or adding data access or security rules—use test-first workflow.
What do I get? / Deliverables
You land failing tests first, implement minimal passing code, refactor safely, and verify 80%+ JaCoCo coverage before treating the change as release-ready.
- Failing then passing JUnit tests
- MockMvc controller tests
- Integration tests with Testcontainers where needed
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Ship → testing is the canonical shelf because the skill enforces coverage gates and integration patterns you rely on before calling a feature done—even though tests are written during Build. Testing subphase reflects JUnit/MockMvc/Testcontainers workflows and JaCoCo enforcement, not deployment or monitoring.
Where it fits
Enforce JaCoCo 80%+ before you tag a release for a solo SaaS API.
Write failing service tests with Mockito before implementing a new market endpoint.
Use MockMvc to lock controller contracts while refactoring authentication rules.
How it compares
A Spring-specific TDD workflow—not a generic “write some unit tests” prompt or a one-shot test generator with no coverage gate.
Common Questions / FAQ
Who is springboot-tdd for?
Indie and solo developers shipping Spring Boot APIs with Claude Code or similar agents who need repeatable JUnit 5, Mockito, and MockMvc habits.
When should I use springboot-tdd?
In Ship → testing before you call a feature done; during Build → backend when adding endpoints, fixing bugs, or refactoring services and security rules.
Is springboot-tdd safe to install?
It guides local test runs and standard Java tooling; review the Security Audits panel on this Prism page for the everything-claude-code bundle before install.
SKILL.md
READMESKILL.md - Springboot Tdd
# Spring Boot TDD Workflow TDD guidance for Spring Boot services with 80%+ coverage (unit + integration). ## When to Use - New features or endpoints - Bug fixes or refactors - Adding data access logic or security rules ## Workflow 1) Write tests first (they should fail) 2) Implement minimal code to pass 3) Refactor with tests green 4) Enforce coverage (JaCoCo) ## Unit Tests (JUnit 5 + Mockito) ```java @ExtendWith(MockitoExtension.class) class MarketServiceTest { @Mock MarketRepository repo; @InjectMocks MarketService service; @Test void createsMarket() { CreateMarketRequest req = new CreateMarketRequest("name", "desc", Instant.now(), List.of("cat")); when(repo.save(any())).thenAnswer(inv -> inv.getArgument(0)); Market result = service.create(req); assertThat(result.name()).isEqualTo("name"); verify(repo).save(any()); } } ``` Patterns: - Arrange-Act-Assert - Avoid partial mocks; prefer explicit stubbing - Use `@ParameterizedTest` for variants ## Web Layer Tests (MockMvc) ```java @WebMvcTest(MarketController.class) class MarketControllerTest { @Autowired MockMvc mockMvc; @MockBean MarketService marketService; @Test void returnsMarkets() throws Exception { when(marketService.list(any())).thenReturn(Page.empty()); mockMvc.perform(get("/api/markets")) .andExpect(status().isOk()) .andExpect(jsonPath("$.content").isArray()); } } ``` ## Integration Tests (SpringBootTest) ```java @SpringBootTest @AutoConfigureMockMvc @ActiveProfiles("test") class MarketIntegrationTest { @Autowired MockMvc mockMvc; @Test void createsMarket() throws Exception { mockMvc.perform(post("/api/markets") .contentType(MediaType.APPLICATION_JSON) .content(""" {"name":"Test","description":"Desc","endDate":"2030-01-01T00:00:00Z","categories":["general"]} """)) .andExpect(status().isCreated()); } } ``` ## Persistence Tests (DataJpaTest) ```java @DataJpaTest @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) @Import(TestContainersConfig.class) class MarketRepositoryTest { @Autowired MarketRepository repo; @Test void savesAndFinds() { MarketEntity entity = new MarketEntity(); entity.setName("Test"); repo.save(entity); Optional<MarketEntity> found = repo.findByName("Test"); assertThat(found).isPresent(); } } ``` ## Testcontainers - Use reusable containers for Postgres/Redis to mirror production - Wire via `@DynamicPropertySource` to inject JDBC URLs into Spring context ## Coverage (JaCoCo) Maven snippet: ```xml <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.14</version> <executions> <execution> <goals><goal>prepare-agent</goal></goals> </execution> <execution> <id>report</id> <phase>verify</phase> <goals><goal>report</goal></goals> </execution> </executions> </plugin> ``` ## Assertions - Prefer AssertJ (`assertThat`) for readability - For JSON responses, use `jsonPath` - For exceptions: `assertThatThrownBy(...)` ## Test Data Builders ```java class MarketBuilder { private String name = "Test"; MarketBuilder withName(String name) { this.name = name; return this; } Market build() { return new Market(null, name, MarketStatus.ACTIVE); } } ``` ## CI Commands - Maven: `mvn -T 4 test` or `mvn verify` - Gradle: `./gradlew test jacocoTestReport` **Remember**: Keep tests fast, isolated, and deterministic. Test behavior, not implementation details.