affaan-m avatar

Springboot Tdd

This is a solid TDD workflow for Spring Boot that covers the full testing pyramid: unit tests with Mockito, MockMvc for controllers, DataJpaTest for repositories, and full integration tests with Testcontainers. It pushes you to write failing tests first, then implement, then refactor, aiming for 80%+ coverage enforced by JaCoCo. The examples are practical, showing real assertions with AssertJ and jsonPath for API testing. Use it when you're building features or fixing bugs and want guardrails to keep your test suite fast and deterministic. The test data builder pattern is a nice touch for readable setup code.

skills.sh installs
5.7K
GitHub stars
300.3K
last updated
Aug 21, 2026

Install

$ npx -y skills add affaan-m/ecc --skill springboot-tdd --agent claude-code

Installs into .claude/skills of the current project.

Files

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)

@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)

@WebMvcTest(MarketController.class)
class MarketControllerTest {
  @Autowired MockMvc mockMvc;
  @MockBean MarketService marketService;

Sponsors

Details

Repository
github.com/affaan-m/ecc
Categories
Testing & QA, Code Review & Quality, Java & JVM
First seen
Jul 14, 2026

More from affaan-m/ecc

All 263
1affaan-m avatarwindows-desktop-e2eaffaan-m/eccE2E testing for Windows native desktop apps (WPF, WinForms, Win32/MFC, Qt) using pywinauto and Windows UI Automation.5.7Kskills.sh installs
2affaan-m avatarswift-protocol-di-testingaffaan-m/eccProtocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.5.4Kskills.sh installs
3affaan-m avatarfsharp-testingaffaan-m/eccF# testing patterns with xUnit, FsUnit, Unquote, FsCheck property-based testing, integration tests, and test organization best practices.5.3Kskills.sh installs
4manaflow-ai avatarcmux-testingmanaflow-ai/cmuxcmux testing rules for Swift Testing, test target compilation, test wiring, and package/refactor validation. Use when adding or changing tests, touching package5.1Kskills.sh installs
5forcedotcom avatardx-devops-test-suite-assignments-configureforcedotcom/sf-skillsRecommends and manages DevOps Center test suite assignments for pipeline stages. Mode A analyzes a commit diff against assigned suite metadata to recommend rele5Kskills.sh installs
6composiohq avatarwebapp-testingcomposiohq/awesome-claude-skillsToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing br4.9Kskills.sh installs