Writing Test Cases¶
Goal of a Test Case¶
A test case should verify reproducible behavior and provide a clear outcome: pass or fail.
Recommended Structure¶
- Name and objective
- Initial conditions
- Stimuli and timing sequence
- Expected signals or states
- Assertions and tolerances
Example Template¶
# TC-001 Motor Speed Follows Setpoint
## Goal
Verify that speed_actual follows speed_setpoint within 1.5 s.
## Setup
- Model: inverter_avg.json
- Initial speed_setpoint: 0
## Stimulus
- t=0.2 s: speed_setpoint = 1200
## Expected Result
- speed_actual reaches 1200 +- 50 by t=1.7 s
## Assertions
- assert abs(speed_actual - 1200) <= 50 for t in [1.6, 1.7]
Good Practice¶
- Use small, focused test cases instead of large end-to-end monoliths
- Use clear naming conventions for signals
- Document thresholds and tolerances explicitly
- Use report export actively for regression tracking