Test Overview
This test checks if the data entered into a form meets the required validation rules. It verifies that invalid data is rejected and valid data is accepted.
This test checks if the data entered into a form meets the required validation rules. It verifies that invalid data is rejected and valid data is accepted.
def validate_age(age): if not isinstance(age, int): return False if age < 0 or age > 120: return False return True def test_validate_age(): assert validate_age(25) == True assert validate_age(-1) == False assert validate_age(130) == False assert validate_age('twenty') == False assert validate_age(0) == True assert validate_age(120) == True if __name__ == '__main__': test_validate_age()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test environment ready, validate_age function loaded | - | PASS |
| 2 | Call validate_age(25) | Function receives integer 25 | Check if 25 is valid age (0 <= 25 <= 120) | PASS |
| 3 | Assert validate_age(25) == True | Function returned True | Age 25 is valid | PASS |
| 4 | Call validate_age(-1) | Function receives integer -1 | Check if -1 is valid age (0 <= -1 <= 120) | PASS |
| 5 | Assert validate_age(-1) == False | Function returned False | Age -1 is invalid | PASS |
| 6 | Call validate_age(130) | Function receives integer 130 | Check if 130 is valid age (0 <= 130 <= 120) | PASS |
| 7 | Assert validate_age(130) == False | Function returned False | Age 130 is invalid | PASS |
| 8 | Call validate_age('twenty') | Function receives string 'twenty' | Check if input is integer | PASS |
| 9 | Assert validate_age('twenty') == False | Function returned False | Non-integer input is invalid | PASS |
| 10 | Call validate_age(0) | Function receives integer 0 | Check if 0 is valid age (0 <= 0 <= 120) | PASS |
| 11 | Assert validate_age(0) == True | Function returned True | Age 0 is valid | PASS |
| 12 | Call validate_age(120) | Function receives integer 120 | Check if 120 is valid age (0 <= 120 <= 120) | PASS |
| 13 | Assert validate_age(120) == True | Function returned True | Age 120 is valid | PASS |
| 14 | Test ends | All assertions passed | - | PASS |