Yueser ← Back to library

AI / Coding and Debugging

Find the gaps in your tests

Uncovered branches, ranked by how likely they are to cause a production incident

Below are my implementation and my existing tests. Find what the tests do not cover: 1) list all branches and boundaries, marking the ones with no case; 2) rank them by 'worst impact if it goes wrong in production' and give the top 5 cases to add (input, expected result, why it is easy to miss); 3) point out which existing cases are duplicates that could be deleted without losing confidence; 4) flag any test that asserts implementation details rather than behavior.

```
[paste the code and tests]
```
How to use

Add the top three first. Leave the rest until something actually breaks — do not try to write them all at once.

Good for

  • You are about to change core payment, coupon or permission logic and the tests were written six months ago.
  • Coverage says 78% but production incidents keep landing on boundary conditions.

Not for

  • The code is not settled yet (the interface changes three times a day): fix the contract first, or the tests chase it.
  • You only want the coverage number to go up: this prompt will tell you which cases are not worth writing.

Example

Input
def apply_coupon(order, coupon):
    if coupon.expired_at < now(): return order
    if order.amount < coupon.min_amount: return order
    if coupon.id in order.used_coupon_ids: return order
    if len(order.applied_coupons) >= 3: return order
    return order._replace(amount=order.amount - coupon.value)

Existing tests: one normal discount, one expired coupon.
What you get
List what is uncovered: amount exactly at the minimum, the same user's second use, stacking past the 3-coupon cap, a result of zero or negative, and the same coupon used by two orders concurrently. Ranked by production impact, the top five should add 'negative total' and 'concurrent reuse'; also point out that the expiry test asserts `_is_expired` was called, which tests implementation rather than behavior.

Common mistakes

  • Pasting the implementation without the existing tests: it cannot tell 'not covered' from 'not shown to me'.
  • Asking it to 'add all missing tests' and getting 40 low-value cases that cost more to maintain than they return.

Try tweaking it like this

  • Add 'give only the input, expected result and why it is easy to miss — no test code' to review the list before anyone writes it.
  • Add 'mark which cases need mocked time or concurrency' to surface gaps in your test infrastructure early.

More in this topic