figure out what problem you are solving test individual
play

Figure out what problem you are solving. Test individual methods - PDF document

Engineering Methodology Requirements Program Debugging Algorithm (Special Topic) TOPICS Example Engineering Methodology Coding Requirements, Algorithm, Example, Coding Testing and Debugging Testing methodologies Test


  1. Engineering Methodology – Requirements Program Debugging Algorithm (Special Topic) TOPICS Example • Engineering Methodology Coding • Requirements, Algorithm, Example, Coding • Testing and Debugging • Testing methodologies Test and Debug CS 160, Fall Semester 2015 1 CS 160, Fall Semester 2015 2 More Detail Testing and Debugging – – ™ Figure out what problem you are solving. ™ Test individual methods before using them. ™ Read the specification very carefully. ™ Not just centerline, also boundary conditions. ™ Figure out how to solve the problem, on paper. ™ Debug your code in a methodical fashion. ™ Make an example of the centerline case. ™ Thoroughly investigate any anomalies in behavior. ™ Add corner cases and error handling later. ™ Make sure to test all the branches in your code. ™ Incremental development is more effective. ™ Anything can be debugged, given enough time. ™ Test each piece by itself. If you haven’t tested it, it doesn’t work! Think before coding! CS 160, Fall Semester 2015 3 CS 160, Fall Semester 2015 4 1

  2. Print Debugging Debugging Tools – – ™ Add a print statement after every operation. ™ Eclipse makes debugging easy. ™ Check the values against your example. ™ Run the program in debug mode (demo). ™ Run several times with different input data. ™ Learn how to set breakpoints. ™ Remove or comment out print statements. ™ Single stepping: ‘step into’ versus ‘step over’. ™ Verify against test suite, if available. ™ Can examine current values of all variables. ™ Check against the assignment specification. ™ More advanced features available. Tedious, but effective, and guaranteed to This is how professional programmers improve assignment scores. debug their code. CS 160, Fall Semester 2015 5 CS 160, Fall Semester 2015 6 Eclipse Debugging (1) Eclipse Debugging (2) – – Starting a debugging session. Setting breakpoints in code. CS 160, Fall Semester 2015 7 CS 160, Fall Semester 2015 8 2

  3. Eclipse Debugging (3) Testing Methodologies – – ™ Unit Testing: verify that each method works. ™ Module Testing: verify that each class works. ™ Integration: verify that classes interact correctly. ™ System Testing: verify that system works as desired. ™ Black Box versus White Box testing ™ Centerline testing versus Corner Cases ™ Checking that Error Conditions are handled ™ Test Driven Development: what is it? Examining the values of variables. CS 160, Fall Semester 2015 9 CS 160, Fall Semester 2015 10 3

Recommend


More recommend