Agent skill
132-java-testing-integration-testing
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. Part of the skills-for-java project
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/skills/other/132-java-testing-integration-testing
Metadata
Additional technical details for this skill
- author
- Juan Antonio Breña Moral
- version
- 0.12.0-SNAPSHOT
SKILL.md
Java Integration testing guidelines
Set up robust integration-test infrastructure for Java services using WireMock to stub outbound HTTP dependencies.
Core areas: Infrastructure topology detection (scanning imports for HttpClient, feign.*, retrofit2.*, RestTemplate, etc.), abstract BaseIntegrationTest base class, WireMockExtension with @RegisterExtension, dynamic port allocation (dynamicPort()), usingFilesUnderClasspath("wiremock"), @BeforeAll + System.setProperty() for coordinate propagation, concrete test classes extending the base class, WireMock JSON mapping files (bodyFileName referencing wiremock/files/), programmatic stub registration via WireMock DSL, per-test stub isolation (register stubs inside each test method), fault injection (503 service unavailable, network latency with withFixedDelay), request verification (WIREMOCK.verify), wiremock-standalone Maven dependency (test scope), and anti-patterns (global @BeforeAll stubs causing order-dependent failures, Mockito-mocked HTTP clients bypassing the real HTTP pipeline, hardcoded ports or URLs in property files).
Prerequisites: Run ./mvnw compile or mvn compile before applying any change. If compilation fails, stop immediately and do not proceed — compilation failure is a blocking condition.
Multi-step scope: Step 1 scans class imports for HTTP client signals and confirms the integration topology with the user (REST → WireMock). Step 2 generates a tailored BaseIntegrationTest.java under src/test/java/{root-package}/ with WireMockExtension and @BeforeAll coordinate propagation, then lists required Maven dependencies. Step 3 generates starter WireMock JSON mapping files (one per confirmed external service) under src/test/resources/wiremock/mappings/{service-name}/.
Before applying changes: Read the reference for detailed examples, good/bad patterns, and constraints.
Reference
For detailed guidance, examples, and constraints, see references/132-java-integration-testing.md.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?