Introduction
When software changes, new problems can sneak in where things used to work fine. Regression testing helps catch these unexpected issues by checking that old features still work after updates.
Imagine you fix a leak in your house's plumbing. Regression testing is like checking all the faucets and pipes afterward to make sure nothing else started leaking because of the repair.
┌───────────────────────────┐
│ Code Change │
└─────────────┬─────────────┘
│
┌───────▼────────┐
│ Regression Test │
└───────┬────────┘
│
┌───────────▼───────────┐
│ Verify Old Features OK │
└───────────┬───────────┘
│
┌───────▼────────┐
│ New Release │
└────────────────┘def add(a, b): return a + b def test_add(): assert add(2, 3) == 5 assert add(-1, 1) == 0 assert add(0, 0) == 0 # Simulate a code change # Now add subtracts instead (bug introduced) def add(a, b): return a - b # Run regression test try: test_add() print("All tests passed") except AssertionError: print("Regression test failed: add function broken")