Download presentation
Presentation is loading. Please wait.
Published byVanessa Hill Modified over 9 years ago
1
Incremental Testing of Functions CSIS 1595: Fundamentals of Programming and Problem Solving 1
2
Incremental Development Key idea: Build and test program one function at a time One method: – Start with “lower level” functions that do not call anything else Could build in order in which called, but not necessary – Implement functions that use tested methods If bug, most likely in function currently being developed – Finish with main program
3
Balloon Program Example Lowest level functions: – set_target() – get_velocity() – compute_miss(target, velocity, angle) – print_row(angle, miss_distance) Then build print_table(target, velocity) – Requires print_row be done first Then main program
4
Unit Testing Testing each function separately Requires – Function definition to be tested – Code to test the function Prompt for inputs (if any) Call function with inputs Print what it returns (if anything)
5
Unit Test Example
6
Unit Test Functions Can create “testing function” for each function – Should keep simple (just get input, call, and print) More complex testing function More likely it has bugs! – Can use to retest a function at any time Bugs suspected Function changed in future versions) Do not delete!
7
Unit Test Function Example Can call from main during testing – If necessary, comment out actual main program during testing
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.