Example 1 — Test every branch of the leap-year rule
Show the steps and the answer
Pick one year for each part of the rule: 2024 (divisible by 4), 2023 (not), 1900 (divisible by 100 but not 400), 2000 (divisible by 400).
Each test aims at a different branch, so whichever branch is coded wrong has a test that catches it.
Write the expected results from the rule: assert isLeapYear(2024) == True; assert isLeapYear(2023) == False; assert isLeapYear(1900) == False; assert isLeapYear(2000) == True.
Expected values must come from the rule, not from running the code, or the tests would just copy the bug.
Run the buggy version: 2024 % 4 = 0 gives True (pass); 2023 % 4 = 3 gives False (pass); 1900 % 4 = 0 gives True (fail); 2000 % 4 = 0 gives True (pass).
Only the 1900 test fails, which points straight at the missing 'divisible by 100' exception.
Answer: Tests: 2024 → True, 2023 → False, 1900 → False, 2000 → True. The buggy version fails only the 1900 test.
Takeaway: Choose one test per branch of the rule and take expected answers from the rule; a failure then names the branch that is wrong.