Test-Driven Development Example
In the previous example, a person must pay 10% income tax if his annual income
is less than 30,000.
A person must pay 15% income tax if his annual income
is equal to or greater than 30,000.
We now want to add a third assertion: If a person's
annual income is greater than 100,000 he must pay
20% income tax.
We add another
test case, which can be hard-coded into
the test driver or inserted into the test case database:
Test Case 3:
Input: income = 200000
Output: tax = 40000
Notice the program being tested will fail Test 3 when this test case
is first introduced. After the program is revised,
it will satisfy this new test in the regression test.