Close
Register
Close Window

CS3 Data Structures & Algorithms

Chapter 2 Programming Tutorials

Show Source |    | About   «  2.12. Mutation Coverage In JUnit   ::   Contents   ::   2.14. Testing for Code Coverage  »

2.13. Testing

2.13.1. Testing vs. Debugging

When we “write a program”, we actually spend most of our time testing and debugging. These are two separate things. Testing refers to determining whether the program operates as we intend. Debugging refers to correcting the program once we determine that it is not operating as we intend. So we can only debug to the extent that we have tested and determined that there is a problem that needs to be corrected. Debugging to fix a known problem can sometimes be extremely hard, but is often somewhat mechanical. Testing requires a lot of skill and empathy, in order to think of all of the ways that a program might go wrong (in particular, all of the input paths to the program that might affect its behavior).

To give you some idea for how hard it is, try doing the following exercise. Your goal is to come up with a series of “tests”, in the form of inputs to the program, that will result in executing the various paths in the program (that is, generating “code coverage”). Here the inputs are meant to be triangle side lengths, and the program is supposed to classify these sidelengths into a type of triangle. You will probably find this quite challenging to come up with various sets of inputs that will get you to even 50% code coverage.

   «  2.12. Mutation Coverage In JUnit   ::   Contents   ::   2.14. Testing for Code Coverage  »

nsf
Close Window