Software Testing Engineering / API & CONTRACT TESTING / TST-019
REST Contract Matrix
Explore concept graphLatihan soal
Live wire test: request, response, assertion
Run with Node 24 at repository root:
node labs/TST-019/http-contract.mjsExpected result:
http-paths=3
http-roundtrips=10
status-matrix=200,201,400,401,403,404,409,500
negative-mutations=3-detected
422=undeclared
target=local-educational-stubSkenario memeriksa success 200/201, invalid amount 400, missing credentials 401, forbidden 403, missing resource 404, duplicate clientReference 409, dan simulated 500. Setiap respons melewati pemeriksaan Content-Type serta subset schema: required fields, tipe primitive, enum, pattern dan optional properties.
Harness juga sengaja membuat tiga respons invalid: status RFC 9457 tidak cocok, 401 tanpa challenge, dan JSON amount berupa number. Ketiganya harus ditolak. Checker tidak mengimplementasikan seluruh spesifikasi JSON Schema atau menguji aplikasi Spring nyata.
Konsep 1 / 3
Compare the required workbook status set to the exact responses promised by SYS-008 OpenAPI.
Coba prediksi atau perbaiki
Can the current SYS-008 contract legitimately be tested as promising HTTP 422?
Kalau jawabanmu berbeda
Kesalahan yang mungkin: Assuming HTTP 422 is supported simply because it exists in the standard.
Mengapa tidak bekerja: The standard lists possible statuses, not commitments made by an individual OpenAPI document.
Coba perbaiki: Validate each operation's declared response map and request a specification change for a new status.
Periksa hasil sendiri
Hasil yang diharapkan: Three explicit operation matrices match OpenAPI and 422 is labeled absent.
Kalau berbeda: Read the actual paths object instead of relying on an external checklist.
Konsep 2 / 3
Run ten real HTTP requests to a local server and verify positive and negative responses.
Coba prediksi atau perbaiki
Why does reading an OpenAPI example not prove a running service returns Location?
Kalau jawabanmu berbeda
Kesalahan yang mungkin: Claiming a test of the local in-memory stub proves Spring controller routing or JWT verification.
Mengapa tidak bekerja: The actual Spring runtime, DB connection and token verifier are never loaded by this exercise.
Coba perbaiki: Run the same contract assertions against an independently implemented target service before claiming integration coverage.
Periksa hasil sendiri
Hasil yang diharapkan: All ten requests complete on a loopback socket and the server is closed cleanly.
Kalau berbeda: Check whether the ephemeral HTTP bind, JSON parser or assertion failed.
Konsep 3 / 3
Reject invalid Problem Details, missing 401 challenge and a breaking amount type mutation.
Coba prediksi atau perbaiki
What is wrong when HTTP status is 409 and problem.status equals 500?
Kalau jawabanmu berbeda
Kesalahan yang mungkin: Sharing one generated response object between the stub and the test oracle without testing failure sensitivity.
Mengapa tidak bekerja: Both sides can drift together and still look green unless wrong responses are actively rejected.
Coba perbaiki: Load the checked-in independent spec in the assertion boundary and add deliberate response mutations.
Periksa hasil sendiri
Hasil yang diharapkan: Three mutated responses fail the checker while normal wire cases pass.
Kalau berbeda: Verify assert.throws wraps the validator and no malformed response bypasses schema or header checks.
Lima soal diagnosis API contract
Jawab tanpa melihat pembahasan dulu. Kamu bisa memperbaiki jawaban dan mencoba lagi. Kuis ini latihan mandiri dan tidak menyimpan skor atau progres.