Software Testing Engineering / API & CONTRACT TESTING / TST-021
Mock Bank Contract
Explore concept graphPraktik dan verifikasi mandiri
Independent Project — Provider Compatibility Gate
Konsep 1 / 3
Define one real Pact consumer contract for the transfer 200 success and a stable 404 error.
Add a new consumer expectation for a suspended account GET in the existing Account API, with an independently defined success body.
Kasus yang berbeda dari contoh: Account success is a different consumer scenario from transfer detail success.
Bukti yang bisa kamu periksa
- A Pact contract produced by invoking a real Account client function and containing the expected status/body.
Jika ingin lanjut
Replay the recorded contract against a real local provider.
Jika terputus: Resume by checking the client's two HTTP requests.
Konsep 2 / 3
Replay the generated Pact through the real Pact provider verifier against a local HTTP provider.
Use a different running provider instance that returns an incorrect 404 body and show Pact verification fails.
Kasus yang berbeda dari contoh: Mutate the not-found problem representation rather than success transfer fields.
Bukti yang bisa kamu periksa
- A separate provider verification with a deliberately invalid RFC 9457 problem status or type.
Jika ingin lanjut
Run a deliberate provider field-type mutation.
Jika terputus: Resume from the healthy provider verification result.
Konsep 3 / 3
Catch a breaking provider amount type mutation before allowing a release.
Mutate a separate response field, such as currency from IDR string to a JSON number, and prove the unchanged Pact rejects it.
Kasus yang berbeda dari contoh: Different response field and type from the amount mutation shown in the lab.
Bukti yang bisa kamu periksa
- An independent failing Pact provider verification for currency type drift with a healthy baseline that still passes.
Jika ingin lanjut
Translate the lab to a real provider test environment, with dependencies stubbed and a versioned Pact broker if needed.
Jika terputus: Resume by comparing the original Pact amount string matcher against the mutated provider payload.
Mock Bank Contract — consumer-driven breaking change
Buat consumer expectation pada layanan bank simulasi, verifikasi provider yang sehat, lalu ubah satu field response secara sengaja agar Pact provider verification gagal tanpa menjalankan full E2E.
Latihan manual — jalankan sendiri di lingkunganmu. Kriteria di bawah adalah pemeriksaan mandiri, bukan penilaian otomatis.
Kriteria selesai
- Consumer test menjalankan fungsi client nyata terhadap Pact mock server dan menghasilkan kontrak yang memiliki success serta error interaction.
- Success 200 memverifikasi amount berbentuk JSON string dan currency; 404 memverifikasi application/problem+json type/title/status.
- Verifier memutar ulang Pact file terhadap HTTP provider lokal yang benar dan lulus pada kedua interaction.
- Provider yang sama sengaja diubah amount dari string menjadi number; verifier menolak, dan negative assertion memastikan hasil itu diobservasi.
- Gunakan Pact 17.1.4 dalam lingkungan test terisolasi; jangan tambahkan runtime dependency ke aplikasi Astro.
- Terapkan kasus independen memakai field currency atau response Account yang berbeda dari contoh amount.
- Pisahkan bukti lab Node lokal dari verifikasi provider Spring nyata, keamanan, bank eksternal dan settlement.
Kriteria verifikasi mandiri
- Mampu menjelaskan siapa yang menentukan consumer contract dan bagaimana Pact mock server menghasilkannya.
- Mampu membedakan consumer mock test dari provider verification.
- Paham alasan perubahan amount JSON string menjadi number harus gagal sebelum deploy.
- Tidak menyatakan bahwa pengujian Pact lokal otomatis membuktikan integrasi produksi.