Learning on Web Dev Open is free for all.

Interview Prep · AI CodingHave a model write the tests, then find what it missed
← AI Coding

Have a model write the tests, then find what it missed

Medium35 minFree, no account

Generated tests cluster around the happy path and are judged by their count.


The question

Here is the spec for a discount engine. Have a model generate a test suite, then review it: what is missing, what is redundant, and what is wrong?

The spec
applyDiscounts(cart, codes) → { total, applied[], rejected[] }

· PERCENT codes take n% off the subtotal
· FIXED codes take a fixed amount off, never below zero
· Only one PERCENT code may apply; the largest wins
· FIXED codes stack, applied after PERCENT
· Expired or not-yet-active codes are rejected with a reason
· Codes may be restricted to categories; they apply only to
  the matching subtotal
· The total is rounded to the nearest cent, half up
35:00Commit to an answer before you open the solution. Reading it first teaches you to recognise good answers, which is not the skill being tested.

Stuck?

0 of 3 hints taken

The worked solution

written by a person · not a grade

Score yourself

0 of 5 marked
  • Identified that the suite covers rules but not interactions30
  • Named specific missing interaction cases25
  • Caught rounding and the zero floor under stacking15
  • Proposed property-based tests for the invariants20
  • Reviewed assertions, not only cases10

We run no AI here and nothing on this page grades you. The score is yours, and the useful number is the one you get on the same problem a month from now, cold.

kept in this browser only