xu-xiang/everything-claude-code-zh/springboot-tdd
Claude Code and agent skill by xu-xiang/everything-claude-code-zh
Trust tier 2
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
使用 JUnit 5、Mockito、MockMvc、Testcontainers 和 JaCoCo 进行 Spring Boot 的测试驱动开发 (TDD)。在添加功能、修复 Bug 或进行重构时使用。
Install
npx vskill@latest install xu-xiang/everything-claude-code-zh/springboot-tddSKILL.md
Spring Boot TDD 工作流
针对具有 80% 以上覆盖率(单元测试 + 集成测试)的 Spring Boot 服务的 TDD 指南。
适用场景
- 新功能或 API 端点开发
- Bug 修复或重构
- 添加数据访问逻辑或安全规则
工作流
1) 先写测试(测试应当失败) 2) 实现通过测试的最简代码 3) 在测试通过的情况下重构代码 4) 强制执行覆盖率检查 (JaCoCo)
单元测试 (JUnit 5 + Mockito)
模式:
- 准备-执行-断言 (Arrange-Act-Assert)
- 避免部分 Mock;优先使用显式打桩 (Stubbing)
- 使用
@ParameterizedTest处理用例变体
Web 层测试 (MockMvc)
集成测试 (SpringBootTest)
持久层测试 (DataJpaTest)
Testcontainers
- 使用可重用的 Postgres/Redis 容器来镜像生产环境
- 通过
@DynamicPropertySource将 JDBC URL 注入到 Spring 上下文中
测试覆盖率 (JaCoCo)
Maven 配置片段:
断言 (Assertions)
- 为了提高可读性,优先使用 AssertJ (
assertThat) - 对于 JSON 响应,使用
jsonPath - 对于异常:
assertThatThrownBy(...)
测试数据生成器 (Test Data Builders)
CI 命令
- Maven:
mvn -T 4 test或mvn verify - Gradle:
./gradlew test jacocoTestReport
记住:保持测试快速、隔离且具有确定性。测试行为,而不是实现细节。
Security
- Security scanPassed, 96 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/springboot-tdd/SKILL.md
Popularity
- Repository stars
- 229
- Repository forks
- 48
- 7-day trend score
- 27
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/xu-xiang/everything-claude-code-zh/springboot-tdd)