Regression test FAQ
How can you tell a regression test caught the bug?
Run the test on the code with the bug, then on the fix. The first run should reproduce the bug; the second should pass the same check.
Test for duplicate receipts
Suppose refreshing an order confirmation sends the receipt a second time. The test needs to count receipts for that order after a refresh. A failure somewhere else, such as the checkout page not loading, tells you nothing about the duplicate.
- On the original code, pay for a test order with receipts going to a test inbox. Refresh its confirmation page once. The test expects one receipt and should find two.
- Reset the order and inbox to the same starting state. Run the same test on the proposed fix. It should now find one receipt.
Keep both runs and their code revisions so another person can compare them. If an agent can edit the test in its pull request, keep a separate copy of this check that it can't change. The expected count stays at one in both runs.
What if the original run fails during setup?
A missing dependency or a timeout can stop the test before it checks the bug. Fix that problem and run it again. You need to see the assertion about the bug fail on the original code.