702-technologies-wiremock
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWireMock best practices
WireMock 最佳实践
Help teams use WireMock effectively for HTTP dependency stubbing with stable, isolated tests.
What is covered in this Skill?
- Stub isolation: per-test registration, , avoiding leaked global stubs
resetAll() - Request matching: method, path, headers, query, body patterns; when broad patterns are acceptable
- Responses: status, headers, JSON/XML bodies, / classpath fixtures, fault simulation (delays, errors)
bodyFileName - Dynamic ports and propagating base URLs into the system under test
- Verification of outbound HTTP calls and debugging unmatched requests
- Clear delegation to framework integration-test skills for test class layout and extensions
Scope: Portable WireMock behavior only. For , , and stack-specific integration tests, use , , , or . For OpenAPI contract quality, use .
BaseIntegrationTestWireMockExtension@132-java-testing-integration-testing@322-frameworks-spring-boot-testing-integration-tests@422-frameworks-quarkus-testing-integration-tests@522-frameworks-micronaut-testing-integration-tests@701-technologies-openapi帮助团队有效使用WireMock进行HTTP依赖项存根,实现稳定、隔离的测试。
本技能涵盖哪些内容?
- 存根隔离:每测试注册、、避免全局存根泄漏
resetAll() - 请求匹配:方法、路径、请求头、查询参数、请求体模式;何时可使用宽泛模式
- 响应处理:状态码、响应头、JSON/XML响应体、/类路径 fixture、故障模拟(延迟、错误)
bodyFileName - 动态端口及将基础URL传递到被测系统
- 验证出站HTTP调用并调试未匹配的请求
- 明确委托给框架集成测试技能处理测试类布局与扩展
适用范围:仅适用于可移植的WireMock行为。如需了解、以及特定技术栈的集成测试,请使用、、或。如需OpenAPI契约质量相关内容,请使用。
BaseIntegrationTestWireMockExtension@132-java-testing-integration-testing@322-frameworks-spring-boot-testing-integration-tests@422-frameworks-quarkus-testing-integration-tests@522-frameworks-micronaut-testing-integration-tests@701-technologies-openapiConstraints
约束条件
Keep recommendations at the WireMock and HTTP-stub layer unless the user explicitly asks for framework integration. After editing this repository's XML sources, regenerate skills and verify the build.
- MANDATORY: Run or
./mvnw compilebefore proposing Java or Maven changes in the same change setmvn compile - FRAMEWORK: Defer /
@SpringBootTest/@QuarkusTestand extension setup to@MicronautTestor the matching@132-java-testing-integration-testing/322/422integration-test skill522 - CONTRACTS: Defer OpenAPI document structure and linting to
@701-technologies-openapi - MANDATORY: Regenerate skills with after editing skill or system-prompt XML in this repo
./mvnw clean install -pl skills-generator - VERIFY: Run or
./mvnw clean verifybefore promoting changesmvn clean verify
除非用户明确询问框架集成相关内容,否则仅在WireMock和HTTP存根层面给出建议。编辑本仓库的XML源文件后,需重新生成技能并验证构建。
- 强制要求:在同一变更集中提交Java或Maven修改前,先运行或
./mvnw compilemvn compile - 框架相关:将/
@SpringBootTest/@QuarkusTest及扩展设置相关内容委托给@MicronautTest或对应的@132-java-testing-integration-testing/322/422集成测试技能522 - 契约相关:将OpenAPI文档结构与校验相关内容委托给
@701-technologies-openapi - 强制要求:编辑本仓库中的技能或系统提示XML后,需运行重新生成技能
./mvnw clean install -pl skills-generator - 验证要求:在推广变更前,运行或
./mvnw clean verifymvn clean verify
When to use this skill
何时使用本技能
- Design or review WireMock stubs (JSON mappings or Java DSL)
- Improve request matching, isolation, or reset strategy for HTTP mocks
- Add or fix verification of outbound HTTP calls to a WireMock server
- Debug flaky tests involving WireMock or unmatched request journals
- Stub external HTTP APIs in tests with stable fixtures and dynamic ports
- 设计或评审WireMock存根(JSON映射或Java DSL)
- 改进HTTP模拟的请求匹配、隔离或重置策略
- 添加或修复对WireMock服务器的出站HTTP调用验证
- 调试涉及WireMock或未匹配请求日志的不稳定测试
- 使用稳定的fixture和动态端口在测试中存根外部HTTP API
Reference
参考资料
For detailed guidance, examples, and constraints, see references/702-technologies-wiremock.md.
如需详细指南、示例及约束条件,请查看references/702-technologies-wiremock.md。