service-virtualization
Simulates external and third-party services in tests with stubs, fakes and simulated servers: contract-based responses, errors, timeouts, request checks and drift checks. Use when the user says 'mock this external API' or 'stub the payment provider'. Not for owned service agreements (use contract-testing).
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- service-virtualization
- license
- Apache-2.0
- description
- Simulates external and third-party services in tests with stubs, fakes and simulated servers: contract-based responses, errors, timeouts, request checks and drift checks. Use when the user says 'mock this external API' or 'stub the payment provider'. Not for owned service agreements (use contract-testing).
- argument-hint
- [external service or dependency]
02 资源文件 3
- 参考文档references/java.md1.3 KB
- 参考文档references/python.md1.1 KB
- 参考文档references/typescript.md1.3 KB
03 SKILL.md 正文
service-virtualization
Objective
Real third-party services are slow, costly, rate-limited and hard to break on purpose. A simulated service makes tests fast and repeatable, and it can return the errors and delays that the real service shows only in an incident. The risk is a simulation that drifts from reality. This skill builds simulations from the contract and keeps them honest.
Context
- Read
.agents/qa-project-context.mdif it exists. Use its external services and environments. - If it does not exist, find the external calls in the code and the configuration. Suggest
qa-project-contextonce. Do not stop the work for it.
Discovery questions
- Which external services does the system call? Which of them does the team own?
- Is there a contract, a sandbox, or recorded traffic for each one?
- Which failures of the dependency must the system handle: errors, timeouts, slow responses, rate limits, bad data?
Principles
- Simulate only what you do not own or cannot run in a test. Use the real thing for your own services and data stores.
- Responses come from the contract or recorded traffic, not from what the code under test expects.
- Simulate failures on purpose: error codes, timeouts, slow responses, malformed bodies, rate limits.
- Verify the requests that matter: the system sent the right call with the right data, and did not send it on failure.
- Check for drift: run a small set of checks against the real service or its sandbox on a schedule, and update the simulation when it differs.
Workflow
- List the dependencies in scope, with their operations, contract and failure modes.
- Choose the level of simulation: an in-process fake for unit tests, a simulated HTTP server for API and integration tests, or the provider's sandbox for a few scheduled checks.
- Build the stubs from the contract: success, each documented error, timeout, slow response, malformed response, rate limit.
- Point the system to the simulation through configuration (base URL, client settings), not through code changes.
- In each test, set the stub for the case, run the action, check the system's result, and verify the outgoing request when it matters.
- Add a scheduled drift check against the real sandbox, if one exists.
Stack recipes
Read only the recipe for the stack of the project: Java, TypeScript and JavaScript, Python. For another stack, apply the principles with the project's own tools, and say so.
Anti-patterns
- Stubs written from the code's expectations. They agree with the bug.
- Only the happy path is simulated. The error handling is never tested.
- One global stub set for all tests. Tests depend on each other's setup.
- Never checking the real service. The simulation drifts, and production fails.
Done when
- Each dependency in scope has stubs for success, each documented error, a timeout and a slow response.
- Tests verify the important outgoing requests and the system's behavior for each failure.
- The simulation is configured, not hard-coded, and each test sets its own stubs.
- A drift check exists, or its absence is stated as a risk.
Related skills
api-testing: the system's own API under these conditions.contract-testing: for services that the team owns.test-environments: where the simulated services run.unit-testing: in-process fakes.
04 同仓库更多 Skills
unit-testing
Writes, fixes or improves unit tests for rules, calculations, validation and state logic: arrange-act-assert, exact oracles, boundary sets, doubles only at boundaries, controlled clock and randomness. Use when the user says 'write unit tests', 'TDD this' or 'mock this dependency'. Not for HTTP endpoints (use api-testing).
ui-automation
Writes, fixes or structures browser end-to-end tests for critical journeys: role, label or test ID locators, auto-waiting assertions, API data setup, page objects, auth reuse and traces. Use when the user says 'UI test', 'end-to-end test' or 'our UI tests are brittle'. Not for business rules (use unit-testing).
testcase-reviewer
Reviews automated tests or manual test cases like a senior test architect: scores fidelity, oracles, assertion depth, edge cases and determinism, and finds tests that pass on wrong code. Use when the user says 'review my tests', 'test smells' or 'review AI-written tests'. Not for fault injection (use mutation-probe).
testability-review
Scores how testable a feature, module or design is before tests exist (seams for clock, randomness and network, hidden state, observability) and gives the smallest production change per blocker. Use when the user asks 'is this testable' or 'why is this hard to test'. Not for writing the tests (use unit-testing).
test-strategy
Writes a test strategy for a product, system or team: quality goals, test levels and their share, environments, data, automation scope, non-functional testing, metrics and a roadmap. Use when the user says 'test strategy' or 'QA strategy'. Not for one sprint or release plan (use test-planning).
test-runner
Finds how a project runs its tests, runs the right subset, and triages each failure as product bug, test defect, environment problem or flaky test, with evidence. Use when the user says 'run the tests' or asks 'which tests fail and why'. Not for pipeline design (use ci-cd-integration).