SKILL

springboot-tdd

Test-driven development for Spring Boot using JUnit 5, Mockito, MockMvc, Testcontainers, and JaCoCo. Suitable when adding features, fixing bugs, or refactoring.

Machine translation
Read the original Chinese text

使用JUnit 5、Mockito、MockMvc、Testcontainers和JaCoCo进行Spring Boot的测试驱动开发。适用于添加功能、修复错误或重构时。

Target: Software development & testing. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original Chinese text

Topics in the source

  • Spring Boot TDD 工作流程
  • 何时使用
  • 工作流程
  • 单元测试 (JUnit 5 + Mockito)
  • Web 层测试 (MockMvc)
  • 集成测试 (SpringBootTest)
  • 持久层测试 (DataJpaTest)
  • Testcontainers

适用于 Spring Boot 服务、覆盖率 80%+(单元 + 集成)的 TDD 指南。 新功能或端点 错误修复或重构 添加数据访问逻辑或安全规则 1. 先写测试(它们应该失败) 2. 实现最小代码以通过测试 3. 在测试通过后进行重构 4. 强制覆盖率(JaCoCo) 模式: Arrange-Act-Assert 避免部分模拟;优先使用显式桩 使用 @ParameterizedTest 处理变体 对 Postgres/Redis 使用可复用的容器以镜像生产环境 通过 @DynamicPropertySource 连接,将 JDBC URL 注入 Spring 上下文 Maven 片段: 为可读性,优先使用 AssertJ (assertThat) 对于 JSON 响应,使用 jsonPath 对于异常:assertThatThrownBy(...) Maven: mvn -T 4 test 或 mvn verify Gradle: ./gradlew test jacocoTestReport 记住:保持测试快速、隔离且确定。测试行为,而非实现细节。

Source repository
affaan-m/ECC
Source file
docs/zh-CN/skills/springboot-tdd/SKILL.md
Fixed revision
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Read the complete original documentation ↗

Requirements

  • Only the author’s Skill metadata is included. Read the full instructions to check dependencies, licensing and conditions of use.

A small first task

先阅读原作者说明,再决定是否在自己的 AI 工具中使用。

Instructions for your AI tool

Author documentation is not live verification by this site. Without evidence, we do not mark a resource as compatible, safe or free.

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T15:01:42.634Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.