132-java-testing-integration-testing

仓库创建 2025年2月9日最近提交 3 天前SkillHot 收录 21 天前
▸ 精选理由

自动识别 HTTP 客户端并生成基类,减少测试套件搭建工作

这个 Skill 做什么

构建与优化 Java 集成测试基础设施,使用 WireMock 模拟外部 HTTP

帮你搭建和改进 Java 的集成测试基础设施,主要用 WireMock 来模拟外部 HTTP 依赖,会生成 BaseIntegrationTest、WireMockExtension 等样板代码。适合需要编写、评审或改良 integration tests、识别 HTTP client(如 feign/RestTemplate/HttpClient)并注入运行时配置的时候使用。重点避免常见反模式(比如用 Mockito 去 mock HTTP 客户端或全局注册 stub),并支持按方法隔离 stub、生成 bodyFileName 映射以及用 System.setProperty 动态注入服务坐标。

▸ 展开 SKILL.md 英文原文

Use when you need to set up, review, or improve Java integration tests — including generating a BaseIntegrationTest.java with WireMock for HTTP stubs, detecting HTTP client infrastructure from import signals, injecting service coordinates dynamically via System.setProperty(), creating WireMock JSON mapping files with bodyFileName, isolating stubs per test method, verifying HTTP interactions, or eliminating anti-patterns such as Mockito-mocked HTTP clients or globally registered WireMock stubs. This should trigger for requests such as Review Java code for integration tests; Apply best practices for integration tests in Java code; Write Java integration tests with real infrastructure boundaries; Improve Testcontainers integration tests for Java code; Review integration test setup and teardown in Java projects. Part of Plinth Toolkit

开发编程Java集成测试WireMock通用
423
Stars
89
Forks
40
仓库内 Skill
+9
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/jabrena/plinth/main/skills/132-java-testing-integration-testing/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/jabrena/plinth/main/skills/132-java-testing-integration-testing/SKILL.md"
SKILL.MD 节选查看完整文件 ↗
# Java Integration testing guidelines

Set up robust integration-test infrastructure for Java services using WireMock to stub outbound HTTP dependencies.

**What is covered in this Skill?**

- Infrastructure topology detection: scanning imports for `HttpClient`, `feign.*`, `retrofit2.*`, `RestTemplate`
- Abstract `BaseIntegrationTest` base class
- `WireMockExtension` with `@RegisterExtension`, dynamic port allocation (`dynamicPort()`)
- `usingFilesUnderClasspath(wiremock)`, `@BeforeAll` + `System.setProperty()` for coordinate propagation
- WireMock JSON mapping files (`bodyFileName` referencing `wiremock/files/`)
- Programmatic stub registration via WireMock DSL
- Per-test stub isolation: re
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有