springboot-tdd — Claude Code skill: TDD and installation
A Spring Boot TDD workflow that starts with failing tests, then implementation and refactoring. Use it for features, bug fixes, and API work.
npx skills add affaan-m/ECC --skill springboot-tdd -a claude-codeWhat springboot-tdd does
springboot-tdd guides Spring Boot development through tests. The agent writes a failing test first, adds the smallest implementation that passes, then refactors while the suite stays green. It covers new endpoints, bug fixes, data access logic, and security rules.
The skill includes patterns for JUnit 5, Mockito, MockMvc, SpringBootTest, and DataJpaTest. Testcontainers examples use Postgres or Redis for integration checks, while JaCoCo enforces coverage at 80%+. Assertions use AssertJ and jsonPath. CI commands include mvn -T 4 test, mvn verify, and ./gradlew test jacocoTestReport.
Install it when your Spring Boot project needs a defined TDD loop and coverage checks. Skip it for work that does not involve tests, integration scenarios, or coverage reporting.
What it helps with
- write tests before implementing Spring Boot features
- exercise REST endpoints with MockMvc
- check repositories and persistence behavior
- run Postgres or Redis through Testcontainers
- enforce coverage with JaCoCo
Example prompts for the agent
- Add a market creation endpoint with TDD. Start with a failing test.
- Write unit tests for `MarketService` using JUnit 5 and Mockito.
- Test the repository against Postgres with Testcontainers and `@DataJpaTest`.
How to install springboot-tdd
1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill springboot-tdd -a claude-code2Manually: put the files in place
~/.claude/skills/springboot-tdd/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/springboot-tdd/
1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill springboot-tdd -a codex2Manually: put the files in place
.agents/skills/springboot-tdd/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill springboot-tdd -a cursor2Manually: put the files in place
.cursor/skills/springboot-tdd/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install affaan-m/ECC springboot-tdd2Manually: put the files in place
.github/skills/springboot-tdd/SKILL.md1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill springboot-tdd -a gemini-cli2Platform CLI
gemini skills install https://github.com/affaan-m/ECC --path skills/springboot-tddManually: put the files in place
.devin/skills/springboot-tdd/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill springboot-tdd -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set146
The whole set →Similar
Questions about springboot-tdd
How do I install springboot-tdd in Claude Code?
Run npx skills add affaan-m/ECC --skill springboot-tdd -a claude-code. The skill file is placed at ~/.claude/skills/springboot-tdd/SKILL.md.
What does springboot-tdd do?
It defines a Spring Boot TDD loop: write a test, implement the minimum code, refactor, and check coverage. The workflow includes unit, web, integration, and persistence tests.
What does springboot-tdd need for integration tests?
Database and cache scenarios use Testcontainers with Postgres or Redis. @DynamicPropertySource injects the container JDBC URLs into the Spring context.
Source text
SKILL.md · MIT
---
name: springboot-tdd
description: Test-driven development for Spring Boot using JUnit 5, Mockito, MockMvc, Testcontainers, and JaCoCo. Use when adding features, fixing bugs, or refactoring.
metadata:
origin: ECC
---
# 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.
© affaan-m · MIT · affaan-m/ECC