
Springboot Tdd
- 1.4k installs
- 238k repo stars
- Updated August 5, 2026
- affaan-m/ecc
This is a copy of springboot-tdd by affaan-m - installs and ranking accrue to the original listing.
springboot-tdd is a Claude Code skill that enforces test-driven development on Spring Boot services using JUnit 5, Mockito, MockMvc, Testcontainers, and JaCoCo for developers adding features or fixing bugs.
About
springboot-tdd is an ECC skill for test-driven development on Spring Boot services with a target of 80%+ unit and integration coverage enforced through JaCoCo. The workflow follows classic TDD: write failing tests first, implement minimal passing code, refactor while green, and verify coverage gates. It applies when adding endpoints, fixing bugs, refactoring, or introducing data-access and security logic. The stack includes JUnit 5 for unit tests, Mockito for mocks, MockMvc for web layer tests, and Testcontainers for integration scenarios. Developers reach for springboot-tdd when they want agent-guided red-green-refactor discipline on Java Spring Boot backends rather than ad hoc test-after coding.
- 80%+ combined unit and integration test coverage enforced by JaCoCo
- 4-step red-green-refactor workflow that guarantees tests fail first
- JUnit 5 + Mockito + MockMvc + Testcontainers patterns included
- Arrange-Act-Assert and @ParameterizedTest usage rules
- Guidance for new features, bug fixes, data access, and security rules
Springboot Tdd by the numbers
- 1,401 all-time installs (skills.sh)
- +84 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/affaan-m/ecc --skill springboot-tddAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1.4k |
|---|---|
| repo stars | ★ 238k |
| Last updated | August 5, 2026 |
| Repository | affaan-m/ecc ↗ |
How do you do TDD on a Spring Boot service?
Follow strict test-driven development when creating or changing Spring Boot services.
Who is it for?
Java developers building or refactoring Spring Boot APIs who want strict red-green-refactor TDD with Mockito, MockMvc, and Testcontainers.
Skip if: Frontend-only projects, non-JVM stacks, or teams that do not enforce coverage gates with JaCoCo on Spring Boot services.
When should I use this skill?
The user adds Spring Boot features, fixes backend bugs, refactors services, or asks for TDD with JUnit 5, MockMvc, or Testcontainers.
What you get
Spring Boot implementations with JUnit 5 unit tests, MockMvc web tests, Testcontainers integration tests, and JaCoCo coverage reports at 80%+.
- JUnit 5 test suites
- MockMvc and Testcontainers integration tests
- JaCoCo coverage reports
By the numbers
- Targets 80%+ unit and integration coverage enforced with JaCoCo
- Stacks JUnit 5, Mockito, MockMvc, and Testcontainers for Spring Boot TDD
Files
Flujo de Trabajo TDD en Spring Boot
Orientación TDD para servicios Spring Boot con 80%+ de cobertura (unit + integración).
Cuándo Usar
- Nuevas funcionalidades o endpoints
- Correcciones de bugs o refactorizaciones
- Agregar lógica de acceso a datos o reglas de seguridad
Flujo de Trabajo
1) Escribir pruebas primero (deben fallar) 2) Implementar el código mínimo para que pasen 3) Refactorizar con pruebas en verde 4) Exigir cobertura con JaCoCo
Pruebas Unitarias (JUnit 5 + Mockito)
@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());
}
}Patrones:
- Arrange-Act-Assert
- Evitar mocks parciales; preferir stubbing explícito
- Usar
@ParameterizedTestpara variantes
Pruebas de Capa Web (MockMvc)
@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());
}
}Pruebas de Integración (SpringBootTest)
@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());
}
}Pruebas de Persistencia (DataJpaTest)
@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
- Usar contenedores reutilizables para Postgres/Redis que reflejen producción
- Conectar mediante
@DynamicPropertySourcepara inyectar URLs JDBC en el contexto de Spring
Cobertura (JaCoCo)
Fragmento Maven:
<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>Aserciones
- Preferir AssertJ (
assertThat) para legibilidad - Para respuestas JSON, usar
jsonPath - Para excepciones:
assertThatThrownBy(...)
Builders de Datos de Prueba
class MarketBuilder {
private String name = "Test";
MarketBuilder withName(String name) { this.name = name; return this; }
Market build() { return new Market(null, name, MarketStatus.ACTIVE); }
}Comandos de CI
- Maven:
mvn -T 4 testomvn verify - Gradle:
./gradlew test jacocoTestReport
Recuerda: Mantener las pruebas rápidas, aisladas y deterministas. Probar comportamiento, no detalles de implementación.
Related skills
How it compares
Use springboot-tdd for Java Spring Boot red-green-refactor; use generic testing skills for non-JVM frameworks or test-after workflows.
FAQ
Which testing libraries does springboot-tdd use?
springboot-tdd uses JUnit 5, Mockito, MockMvc, and Testcontainers for Spring Boot unit, web, and integration tests, with JaCoCo enforcing coverage targets after each TDD cycle.
What coverage target does springboot-tdd require?
springboot-tdd targets 80%+ combined unit and integration coverage on Spring Boot services, verified through JaCoCo as part of the red-green-refactor workflow.
When should developers invoke springboot-tdd?
springboot-tdd fits new Spring Boot endpoints, bug fixes, refactors, and data-access or security changes where tests must be written before implementation.