Contract Testing Strategy

    1

    Plans tool-agnostic consumer/provider contract testing across services: seams, provider states, versions, deploy checks.

    $5

    Secure checkout via Stripe

    30-day refund guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI tools you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseOpenClawOpenClaw+21 more

    Contract Testing Strategy

    Example session with this skill installed

    Design the microservices contract testing strategy for our Order-to-Payment service seam before our Q4 release.

    • Subject: Order Service (consumer) invoking Payment Service v2.4 (provider) via POST /v1/charges (run-id: checkout-payment-cts-001).
    • Deciders: Quality Engineering Lead (David O'Reilly) and Principal Backend Architect (Marcus Vance).
    • Seam Details: 8 distinct interaction states including successful capture, card declined, expired idempotency key, and 3DS challenge required.
    • Tension: Tech lead proposed deploying an end-to-end staging environment with mock payment servers and testing via nightly Cypress/Postman runs; David O'Reilly objects that staging environments flake frequently (incident INC-3180 delayed release by 4 days due to stale test data) and insists on fast, tool-agnostic consumer-driven contract testing with deterministic provider states and automated CI deployment gates.
    • Deployment Gate: Automated matrix verification (can-i-deploy) preventing production release if consumer and provider versions are incompatible.

    Write the contract testing strategy specification under docs/.

    • Read your context and instructions
    • Compiled the contract testing strategy

    Wrote docs/architecture/tasks/checkout-payment-cts-001/contract-testing-strategy/contract-testing-strategy.md. Complete tool-agnostic contract testing strategy specifying consumer interaction expectations, provider state fixtures, CI deployment gating, and breaking change evolution.

    ---
    skill: contract-testing-strategy
    ---
    
    # Contract Testing Strategy: Order-to-Payment Integration Seam [CTS-PAY-001]
    
    ## Summary
    
    This strategy establishes a tool-agnostic contract testing specification for the critical interaction seam between `Order Service` (Consumer) and `Payment Service v2.4` (Provider) on `POST /v1/charges` under run ID `checkout-payment-cts-001`. It decisively rejects fragile, long-running end-to-end staging test environments (which caused incident INC-3180) in favor of consumer-driven contract testing. The specification defines 8 discrete provider states, automated CI compatibility matrix verification (`can-i-deploy`), and forward-compatible schema evolution rules, ensuring zero breaking changes reach production across independent release cycles.
    
    ## Detailed Description
    
    End-to-end testing in staging environments suffers from test data drift, third-party flakiness, and high maintenance costs. In incident INC-3180, an unannounced field removal in Payment Service went undetected by staging mocks, causing 4 days of release delay. Contract testing decouples consumer expectations from live provider infrastructure by treating contract files as versioned, testable boundary assets.
    
    ### Criteria and weights
    
    | Criterion | Why it matters here | Weight | Source of the weight |
    |---|---|---|---|
    | Deterministic CI Fast-Feedback | Contract execution in pull requests must complete in < 60 seconds without live network dependencies. | 0.35 | David O'Reilly (QE Lead) |
    | Flake Elimination & State Control | Provider state setup must deterministically mock card declines and 3DS challenges without external sandboxes. | 0.30 | Post-Mortem INC-3180 |
    | Pre-Deployment Release Gate | Automated verification must block production deployment if deployed versions are incompatible. | 0.20 | Marcus Vance (Principal Architect) |
    | Decoupled Team Independence | Teams must release on independent cadences without synchronized lock-step staging deployments. | 0.15 | Delivery Engineering |
    
    
    ### Comparison
    
    | Testing Strategy Candidate | Feedback Latency | Environmental Flake Risk | Blast Radius Detection | Cost / Overhead | Evaluation |
    |---|---|---|---|---|---|
    | Option A: Live Staging E2E Suite | 45–90 minutes | High (INC-3180 stale data failure) | Late (post-merge staging deploy) | High (dedicated staging cluster) | Rejected: Unstable, slow feedback loops, frequent false positives. |
    | Option B: Provider Unit Mocks Only | < 10 seconds | Zero | Weak (fails to detect consumer drift) | Low | Rejected: Does not guarantee consumer assumptions match provider wire reality. |
    | Option C: Consumer-Driven Contract Testing (Chosen) | < 45 seconds in PR | Zero (isolated mocked unit runs) | Early (PR build time via `can-i-deploy`) | Low (runs in existing CI runners) | Selected: Fast, deterministic, mathematical verification of compatibility. |
    
    
    ### Result
    
    Option C is selected. Consumer generates versioned contract JSON during unit testing; provider verifies contract against deterministic state handlers; deployment matrix gates pipeline promotions.
    
    ---
    
    ### Required Mechanisms
    
    #### 1. Interaction Seam & Endpoint Contract [MC-IS-01]
    - **Endpoint**: `POST /v1/charges`
    - **Consumer**: `order-service`
    - **Provider**: `payment-service v2.4`
    - **Request Specification**:
      ```json
    
    ```json
      {
        "amount_cents": 4500,
        "currency": "USD",
        "payment_method_id": "pm_card_visa_valid",
        "order_id": "ord_88291a",
        "idempotency_key": "IDEMP-ord_88291a"
      }
    
    
    - **Response Specification (`201 Created`)**:
      ```json
      {
        "charge_id": "ch_39481a",
        "status": "SUCCEEDED",
        "amount_cents": 4500,
        "currency": "USD",
        "captured": true,
        "created_at": "2026-09-16T10:00:00Z"
      }
    
    2. Provider States & Verification Matrix [MC-PS-01]

    Provider verification executes against a local instance of Payment Service configured with deterministic state handler fixtures:

    State IdentifierPrecondition DescriptionExpected Response StatusExpected Error / Payload Code
    charge_success_instant_captureCustomer has valid card with sufficient balance201 Createdstatus: "SUCCEEDED"
    card_declined_insufficient_fundsTest token pm_card_insufficient_funds402 Payment Requiredcode: "INSUFFICIENT_FUNDS"
    card_declined_expiredTest token pm_card_expired402 Payment Requiredcode: "CARD_EXPIRED"
    requires_3ds_challengeTest token pm_card_3ds_required409 Conflictstatus: "REQUIRES_ACTION", redirect_url: "..."
    duplicate_idempotency_in_progressLock active on IDEMP-ord_88291a in DB409 Conflictcode: "CONCURRENT_REQUEST"
    duplicate_idempotency_resolvedPrior charge committed with same key201 CreatedIdentical replayed charge_id
    idempotency_payload_mismatchKey reused with different amount_cents422 Unprocessable Entitycode: "PAYLOAD_MISMATCH"
    invalid_request_missing_amountRequest payload omits amount_cents400 Bad Requestcode: "SCHEMA_VALIDATION_ERROR"
    3. Automated Deployment Gate (can-i-deploy) [MC-DG-01]
    • Mechanism: Prior to production container rollout, the CI/CD pipeline queries the central contract matrix registry:
      can-i-deploy \
        --pacticipant order-service \
        --version ${GIT_COMMIT_HASH} \
        --to-environment production
      
    • Evaluation: The registry checks whether the exact consumer commit hash has successfully verified against the currently deployed production version of payment-service.
    • Enforcement: If verification status is FAILED or UNKNOWN, pipeline halts with exit code 1, aborting deployment.
    4. Evolution & Breaking Change Policy [MC-EV-01]
    • Additive Changes: Provider may introduce new optional response fields at any time without coordinating with consumer.
    • Deprecation: Removing or modifying existing fields requires:
      1. Provider marks field deprecated across 1 release cycle.
      2. Consumer updates contract to remove expectation on deprecated field.
      3. Consumer publishes new contract version; registry confirms 0 active consumers require the field.
      4. Provider safely removes field.

    Invariants and Contracts

    Zero Breaking Production Deployments [INV-CTS-01]
      No service deployment to staging or production may proceed without a successful
      `can-i-deploy` verification matrix confirmation against active target environment versions.
    
    Independent State Fixtures [INV-CTS-02]
      Provider states must be self-contained in-memory database seeds. External third-party
      network calls to live payment gateways during provider verification are strictly forbidden.
    
    Strict Contract Consumer Scoping [INV-CTS-03]
      Consumers must assert expectations only on fields they actually read. Asserting
      expectations on unused provider fields (tight coupling) is prohibited during contract generation.
    

    Explicit Unknowns

    • Exact contract matrix registry hosting infrastructure (self-hosted vs managed container) (G-1).
    • Maximum tolerable delay in PR pipelines for running provider state verification suites (G-2).

    Traceability

    ClaimClassificationSourceFreshness
    Order Service to Payment Service v2.4 seamprovidedIntake specificationCurrent
    8 provider states specificationdecidedDavid O'Reilly & Marcus Vance2026-09-16
    Incident INC-3180 4-day release delayprovidedPost-mortem evidenceHistorical
    Automated can-i-deploy matrix gatedecidedQuality Engineering Policy2026-09-16
    Fast-feedback PR execution under 60sprovidedSLA intake constraintCurrent

    Verification

    No validator was supplied, so no command was run.

    Reviewer self-check against contract testing standards:

    • State Coverage: PASS. 8 discrete provider states cover successful capture, card declines, 3DS, and idempotency conflicts.
    • Isolation Check: PASS. Strategy eliminates live staging dependencies; runs purely via mocked contract verification.
    • Pipeline Gating: PASS. Explicit can-i-deploy CLI gate halts deployments on matrix incompatibility.
    • Evolution Rules: PASS. Additive-first and phased deprecation protocols defined.

    Open Decisions

    • DEC-CTS-01: David O'Reilly to finalize whether contract artifact storage will use internal S3 buckets or a dedicated broker container (Owner: David O'Reilly).

    Next steps

    1. Order Service developers integrate consumer contract assertions into existing Jest/Pytest unit suites.
    2. Payment Service developers implement mock state handlers for all 8 defined provider states.
    3. Quality Engineering team integrates can-i-deploy CLI checks into Jenkins/GitHub Actions CD pipelines.

    Connects securely to your tools. The creator never sees your data.

    What you get

    Map consumer and provider seams for decoupled releasesDefine provider states for deterministic API verificationEstablish Can-I-Deploy gates for CI/CD pipelinesSelect testing styles like consumer-driven or bidirectional

    About this skill

    Contract Testing Strategy for Microservices: Full Description

    What it does

    This skill maps authoritative interfaces and delivery dependencies into executable compatibility evidence at participant seams. It separates source specifications, consumer intent artifacts, provider verification and deployment matrices without selecting Pact or replacing integration tests.

    Use it when

    Use when independently delivered participants need bounded evidence that interface changes remain compatible for known dependencies.

    For example: “Healthcare patient portal releases keep breaking the EHR integration service whenever appointment status fields are updated. The EHR team cannot run full end-to-end environments for every frontend pull request.”

    What you get

    • Contract Test Plan
    • Pact Broker Setup Guide
    • Can-I-Deploy Pipeline Integration

    Written as Markdown to <your output folder>/architecture/tasks/<run-id>/contract-testing-strategy/.

    What it will not do

    Do not use for API/event design, schema governance, integration/E2E testing, service virtualization implementation or broker setup.

    How it works

    1. Check seam authority exists.
    2. Inventory consumer and provider seams.
    3. Select compatibility testing style per seam.
    4. Define provider state and interaction semantics.
    5. Establish verification matrices and deployment gates.
    6. Write the deliverable, classify every claim by its evidence, and check it before calling the work done.

    What's in the package

    Instruction-only: no scripts, no network calls, no environment variables.

    • LICENSE.txt
    • SKILL.md
    • agents/openai.yaml
    • assets/output-template-task.md
    • references/domain-rules.md
    • references/operating-rules.md
    • references/output-contract.md

    How to install

    Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.

    ~30 seconds
    1. 1

      Download the ZIP

      Free skills download straight away. Paid skills unlock right after purchase.

    2. 2

      Unzip into your skills folder

      Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.

    3. 3

      Ask your agent to use it

      Restart the agent if it was already running. It picks the skill up automatically - no config needed.

    Skills folder by agent

    Click the path to copy it. Create the folder if it does not exist yet.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    30-day refund

    Not a fit? Get your money back

    Trust & safety

    Security scanned

    Verified clean 13 days ago

    • Passed all security checks, Safe to install

    Listed13 days ago

    What's inside

    Frequently Asked Questions