Introduction
Imagine you fixed a problem in a software but want to be sure that your fix didn't break anything else. This is the challenge regression testing solves by checking that existing features still work after changes.
Think of a car mechanic who fixes the brakes but then tests the whole car to make sure the steering, lights, and engine still work fine. This careful check after a fix is like regression testing in software.
┌───────────────────────────────┐
│ Code Change │
└──────────────┬────────────────┘
│
▼
┌───────────────────────────────┐
│ Regression Testing Run │
│ ┌───────────────┐ ┌─────────┐│
│ │ Full Tests │ │ Partial ││
│ │ (All features)│ │ Tests ││
│ └───────────────┘ └─────────┘│
└──────────────┬────────────────┘
│
▼
┌───────────────────────────────┐
│ Confirm No Existing Features │
│ Are Broken After Changes │
└───────────────────────────────┘import unittest class Calculator: def add(self, a, b): return a + b class TestCalculator(unittest.TestCase): def test_add(self): calc = Calculator() self.assertEqual(calc.add(2, 3), 5) def test_add_negative(self): calc = Calculator() self.assertEqual(calc.add(-1, -1), -2) if __name__ == '__main__': unittest.main()