Test Overview
This test simulates a white-box testing scenario where the tester checks the internal logic of a simple function. It verifies that the function behaves correctly for given inputs by examining its code paths.
This test simulates a white-box testing scenario where the tester checks the internal logic of a simple function. It verifies that the function behaves correctly for given inputs by examining its code paths.
import unittest # Function to test: returns True if number is even, else False def is_even(num): if num % 2 == 0: return True else: return False class TestIsEven(unittest.TestCase): def test_even_number(self): self.assertTrue(is_even(4)) def test_odd_number(self): self.assertFalse(is_even(5)) if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test runner initialized, test cases loaded | - | PASS |
| 2 | Calls is_even(4) | Function executes with input 4 | Checks if 4 % 2 == 0, returns True | PASS |
| 3 | Asserts that is_even(4) returns True | Assertion compares returned value True with expected True | assertTrue passes | PASS |
| 4 | Calls is_even(5) | Function executes with input 5 | Checks if 5 % 2 == 0, returns False | PASS |
| 5 | Asserts that is_even(5) returns False | Assertion compares returned value False with expected False | assertFalse passes | PASS |
| 6 | Test ends | All test cases executed successfully | - | PASS |