Defensive Programming
Testing/validation
Debugging
Set yourself up for testing/debugging
Ready to test?
Ensure code runs - remove syntax errors - remove static semantic errors - Python Interpreter can usually find these Set of Expected results - and input set - for each input a corresponding output
Classes of tests
Unit testing
- testing each function separately
Regression testing
- catch reintroduced errors that were previously fixed
Integration testing
- tend to rush to do this
Testing methods
Intuition
Pick natural boundaries to the problem
Random testing
If no natural partitions
Black Box Testing
Explore paths through specifications
Glass Box Testing
Explore paths through code
More about Black Box testing
Considerations for Black Box testing
More about Glass Box testing
- Called path-complete if every potential path through code is tested at least once
Drawback for Glass Box testing
- missing paths
Guidelines for Glass Box testing
Branches - exercise all parts of a conditional for loops - loop not entered - body of loop executed exactly once - body of loop executed more than once while loops - same as for loops
Runtime bugs
Overt
- Code crashes or runs forever
Covert
- Code returns a value, which may be incorrect but hard to determine
Persistent
Intermittent
- even if run on same input