Agent skill · software engineering · affaan-m
springboot-tdd
使用JUnit 5、Mockito、MockMvc、Testcontainers和JaCoCo进行Spring Boot的测试驱动开发。适用于添加功能、修复错误或重构时。
Why this skill is useful
Provides specific TDD patterns and executable test examples for Spring Boot that the AI wouldn't reliably generate on its own.
What it needs
Requires gradle, maven, testcontainers installed locally. About 1k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.
What this skill does
Spring Boot TDD 工作流程 适用于 Spring Boot 服务、覆盖率 80%+(单元 + 集成)的 TDD 指南。 何时使用 新功能或端点 错误修复或重构 添加数据访问逻辑或安全规则 工作流程 1. 先写测试(它们应该失败) 2. 实现最小代码以通过测试 3. 在测试通过后进行重构 4. 强制覆盖率(JaCoCo) 单元测试 (JUnit 5 + Mockito) 模式: Arrange-Act-Assert 避免部分模拟;优先使用显式桩 使用 @ParameterizedTest 处理变体 Web 层测试 (MockMvc) 集成测试 (SpringBootTest) 持久层测试 (DataJpaTest) Testcontainers 对 Postgres/Redis 使用可复用的容器以镜像生产环境 通过 @DynamicPropertySource 连接,将 JDBC URL 注入 Spring 上下文 覆盖率 (JaCoCo) Maven 片段: 断言 为可读性,优先使用 AssertJ (assertThat) 对于 JSON 响应,使用 jsonPath 对于异常:assertThatThrownBy(...) 测试数据构建器 CI 命令 Maven: mvn -T 4 test 或 mvn verify Gradle: ./gradlew test jacocoTestReport 记住:保持测试快速、隔离且确定。测试行为,而非实现细节。
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills affaan-m/springboot-tdd--107a63