A rebate function must return 500 cents for purchases of at least 10000 cents and zero for smaller purchases. Its only tests check purchases of 2000 cents and 14000 cents, and both pass.
During a proposed refactoring, a developer renames a private helper and changes the rebate threshold from 10000 cents to 11000 cents. Both existing tests still pass. Which statements are correct? Select all that apply.
Adding an assertion for a purchase of 10000 cents would expose the threshold change.
Replacing result assertions with private-helper name checks would better protect the required behavior.
The threshold change alters required behavior even though the existing tests remain green.
Passing both existing tests establishes that the threshold change is a valid refactoring.
Unlock full course notes by signing up
Build expectations before implementation
You are developing a library late-fee function with TDD. The input is a non-negative integer number of overdue days. The first two overdue days are free; each additional day costs 30 cents, with a maximum total fee of 180 cents.
The current implementation returns zero for every input. During test planning, calculate the expected fees for 2, 3, and 9 overdue days. Also determine how many of these three assertions would fail if each were run independently against that unchanged implementation.
Enter each fee in cents as an exact integer and the failure count as an exact integer number of tests.
Trace shared state between TDD tests
During TDD, you develop an integer accumulator whose value starts at zero. Its addition and multiplication operations work correctly. Two tests pass when each creates its own fresh accumulator:
Test A adds 4, then asserts that the value equals 4.
Test B adds 3, multiplies the resulting value by 2, then asserts that the value equals 6.
Choose a minimal set of discriminating examples
You are selecting the next examples for a TDD test list. A reservation function accepts an integer number of seats nnn, from 0 through 10, and returns a charge in cents. Zero seats cost zero. A positive reservation costs 200 cents for the first seat plus 50 cents for each additional seat, capped at 400 cents.
The only existing assertion checks zero seats. Each of the following incomplete implementations passes it:
Each additional test must assert the correct returned charge for exactly one positive integer input. Tests are evaluated separately against each implementation. What is the minimum number of additional test cases needed so that every incomplete implementation fails at least one selected test? Answer as an exact integer number of test cases.