← All Learning Paths

Contract Testing Engineer

Stop integration surprises: consumer-driven contracts, drift detection, OpenAPI fuzzing, golden files, schema compatibility gates, and deprecation with sunset headers.

technicaladvanced8 nodes10.42h total

Path overview

契约测试把接口对不对从集成环境前移到 PR 阶段。本路径从契约漂移的成因讲起,覆盖向后兼容与模式演进的判定规则,再落地契约测试、模糊测试、黄金文件与兼容性门禁四个配方,收尾于废弃流程与评审工作流。

Contract testing moves is-the-interface-right from integration environments to pull requests. This path covers drift, compatibility rules, fuzzing, golden files, gates, and deprecation.

  1. Apply "Add an OpenAPI Contract Test" to a contract testing task, checking that "Run property-based tests against a disposable server so generated requests exercise the" appears after the "Every documented operation returns responses that match the schema, or the failing" step.

    Completion criteria: Deliver a transcript of "Add an OpenAPI Contract Test" with each step's command and observed state, ending at "Every documented operation returns responses that match the schema, or the failing".

    Next step: Fuzz the API Against Its OpenAPI Schema

    ⏱ 0.5h

  2. Execute "Fuzz the API Against Its OpenAPI Schema" end to end, then repeat the last step with one parameter changed and compare "Generate malformed and edge-case requests from the API schema to find unhandled 500".

    Prerequisites: Add an OpenAPI Contract Test

    Completion criteria: Show the command for every step of "Fuzz the API Against Its OpenAPI Schema" and paste the output proving "Generate malformed and edge-case requests from the API schema to find unhandled 500"; then note the step where "A version string such as 3.39.0, confirming the CLI is on PATH." appears.

    Next step: Add Golden File Tests for API Responses

    ⏱ 0.5h

  3. Run "Detect unintended API response changes with committed golden files that are updated" from "Add Golden File Tests for API Responses" and confirm the documented result "UPDATE_GOLDEN=1 creates or rewrites the file; a normal run compares and fails with the file".

    Prerequisites: Fuzz the API Against Its OpenAPI Schema

    Completion criteria: Run "Add Golden File Tests for API Responses" twice — once as written and once with a changed input — and attach both transcripts with the observed difference.

    Next step: Gate Deploys on Schema Compatibility

    ⏱ 0.5h

  4. Apply "Gate Deploys on Schema Compatibility" to a contract testing task, checking that "{compatibility:BACKWARD}" appears after the "Catch breaking event schema changes in pull requests instead of discovering them when" step.

    Prerequisites: Add Golden File Tests for API Responses

    Completion criteria: Deliver a transcript of "Gate Deploys on Schema Compatibility" with each step's command and observed state, ending at "Catch breaking event schema changes in pull requests instead of discovering them when".

    Next step: Add API Deprecation Headers

    ⏱ 0.5h

  5. Execute "Add API Deprecation Headers" end to end, then repeat the last step with one parameter changed and compare "The dashboard shows which clients still depend on the old endpoint.".

    Prerequisites: Gate Deploys on Schema Compatibility

    Completion criteria: Show the command for every step of "Add API Deprecation Headers" and paste the output proving "The dashboard shows which clients still depend on the old endpoint."; then note the step where "Log calls with the client id and endpoint, and build a migration dashboard before the" appears.

    Next step: Review API Contract Changes Before Merge

    ⏱ 0.5h

  6. Follow "Review API Contract Changes Before Merge" and record "Classify each change: Mark additions as compatible and removals, required additions, type" at the step where it should appear, using "No breaking change merges without an owner and a date." as the check.

    Prerequisites: Add API Deprecation Headers

    Completion criteria: Produce a run log for "Review API Contract Changes Before Merge" that ends at "Classify each change: Mark additions as compatible and removals, required additions, type" and mark every step where "No breaking change merges without an owner and a date." was checked.

    Next step: Detect Breaking Changes Between API Contracts

    ⏱ 0.5h

  7. Turn JSON object: { oldSpec: { paths, fields, required }, newSpec: { into [field-removed:name,path-removed:/users/{id},required-added:tenantId] by completing "Detect Breaking Changes Between API Contracts" with a reproducible script and a failing-case note.

    Prerequisites: Review API Contract Changes Before Merge

    Completion criteria: Show the test run for "Detect Breaking Changes Between API Contracts" with two passing samples and one deliberately failing input, with the expected error.

    Next step: Capstone: Contract Testing Engineer

    ⏱ 0.42h

  8. Build "Build a Schema Registry Service" through its phases, keeping "Compatibility checker" independently testable.

    Prerequisites: Review API Contract Changes Before Merge, Detect Breaking Changes Between API Contracts

    Completion criteria: Deliver "Compatibility checker" and paste the test output where the acceptance test passes; include the test name and command.

    Next step: Run the capstone's tests, publish the repository, and demo it to a reviewer.

    ⏱ 4h