Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1regression testing | Aprint(add(2, 3) == 5) | |
| 2for t in tests: run(t) | BRerunning the failed test and all the earlier tests after a fix, to check nothing that used to pass is now broken | |
| 3After fixing a bug, rerun the test that failed to check the fix actually worked | CAssuming earlier tests still pass is wrong. A fix can break other code, so tests 1, 2 and 4 must be rerun and checked. | |
| 4A fix can break code that used to pass, so an earlier passing test can now fail | DOnly the failed test was rerun. The earlier tests were skipped, so the fix may have broken something that used to pass. | |
| 5Fix bug -> rerun only the failed test -> release the program | ERerun every saved test case after a fix, not just the one that failed | |
| 6Test 3 passes after the fix -> assume tests 1, 2 and 4 still pass | Fprint(is_even(4) == True) # passed before the fix, FAIL after |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
regression testing — After fixing a bug, rerun the failed test and all earlier tests, because a fix can break code that used to pass.tests = [(2, 4), (3, 9), (0, 0)]
for n, expected in tests:
print(square(n) == expected)for n, expected in tests:
if square(n) != expected:
print("FAIL", n)def run_tests():
for n, e in tests:
print(square(n) == e)def square(n):
return n * n
run_tests()def double(n):
return n * 2
assert double(4) == 8