Test Overview
This test checks that all possible paths in a simple decision function are executed and verified. It ensures the function behaves correctly for different input values, covering every branch.
This test checks that all possible paths in a simple decision function are executed and verified. It ensures the function behaves correctly for different input values, covering every branch.
def classify_number(num): if num > 0: return "Positive" elif num == 0: return "Zero" else: return "Negative" import unittest class TestClassifyNumber(unittest.TestCase): def test_positive(self): self.assertEqual(classify_number(5), "Positive") def test_zero(self): self.assertEqual(classify_number(0), "Zero") def test_negative(self): self.assertEqual(classify_number(-3), "Negative") if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test runner initialized, tests ready to execute | - | PASS |
| 2 | Runs test_positive: calls classify_number(5) | Function receives input 5 | Return value is 'Positive' | PASS |
| 3 | Runs test_zero: calls classify_number(0) | Function receives input 0 | Return value is 'Zero' | PASS |
| 4 | Runs test_negative: calls classify_number(-3) | Function receives input -3 | Return value is 'Negative' | PASS |
| 5 | All tests complete | All paths in classify_number covered | All assertions passed | PASS |