Loading Engineer Africa…
Loading Engineer Africa…
THE FREE ENGINEERING LAB
Make a request. Find the bug. Prove the fix.
Learn the testing habits that make software more dependable.
API FOUNDATIONS
…/ 03 lessons
Your next useful skill starts here.
LESSON 02 / 03 · 12 MIN
Reproduce a regression, then prove the expected behavior.
The next version of the API is ready for review. The usual order works, but a small change to a comparison operator can quietly move a boundary. You need evidence before you approve the release.
For an allowed interval of 1 through 10, a compact boundary suite checks 0, 1, 10, and 11. These values sit immediately outside and directly on the boundaries. Our candidate build deliberately contains training bugs: it accepts zero items and rejects ten. The reference build follows the contract. Both builds run locally and deterministically; no real checkout is involved.
Teaching simulator: requests run entirely in your browser. They do not contact a server, create orders, or take payments.
400 INVALID_QUANTITY. Above 10: 400 QUANTITY_LIMIT.LEARN10 gives 10% off and ignores letter case. Any other value: 400 INVALID_COUPON.200 with currency, quantity, unitPrice, subtotal, discount, and total. Money uses USD cents. Unit price is 2500; total = subtotal − discount.Run the four contract-based checks on the candidate. Inspect the two failures, then switch to the reference build and run the same suite again.
POST /sandbox/quote
// Send a request to inspect // its actual response here. // Nothing leaves your browser.
JSON data. Match the status and the body fields that matter.
03 / REVIEW THE EVIDENCE
Run your suite to see the result of every assertion.
The checklist below measures coverage as well as correctness.Reproduce both the zero and ten regressions on the candidate build
Check quantity 0 returns status 400 and INVALID_QUANTITY
Check quantity 1 returns status 200 and total 2500
Check quantity 10 returns status 200 and total 25000
Check quantity 11 returns status 400 and QUANTITY_LIMIT
Run a reference suite with every assertion passing
A useful regression test fails on the broken version and passes on the corrected version. A green test that never exposed the bug is weaker evidence.