What the Test Shows
The next step of the plan is the month's total. For it, someone got the function month_total() in an answer, and it's in the program now, with the two lines that print the total. Asked for it, the AI usually writes a correct one. This answer wasn't correct, and it's the kind of mistake a test is for. Run the program: it prints Total: 90.
That looks believable, and the program runs without an error. But add up the weeks on the invoice: 30 + 24 + 24 + 18 = 96. One of the two numbers is wrong, and working it out by hand, as in Tests Come First, tells you which. Write what you worked out as a test, and it checks the function every time you run the program.
A failed test tells you that something is wrong, but not what. That's a question for the AI, as in Finding Mistakes with AI, and the AI needs the program to answer it: attach it with what it printed, and say what you expected. Ask which line to change rather than for a new program. You see what the mistake was, and the rest of your program stays as it is.
Instructions
- 1
At the end of the program, add a test:
print(month_total(weeks) == 96). Run the program: the test printsFalse. - 2
Click Attach to message on the console to attach what the program printed, and the same button over the program to attach
script.py. Say that your test ofmonth_total()printsFalsebecause the total is 90, not 96, and ask which line to change. Then send it. - 3
Make the change in
month_total()and run the program: the invoice saysTotal: 96, and your new test printsTrue.