Lab Handout: Week
Testing in an interesting problem in Computer Science, without a great answer. The only way to really know that a program is correct is to prove it. In the absence of rigorous proofs, our next best idea is testing --- lots and lots of testing. But testing is only as good as the test cases that are used… In the case of binary search trees, there are an infinite number of possible trees; you cannot test them all. Instead, you try to create as many test cases as possible while capturing as many different varieties as you can. Some test cases are obvious: an empty tree, a tree with one node, a tree with two nodes, etc. After that, you try to create random trees of various sizes with the hope of revealing flaws in the code. In CS 251, we have used two different testing styles to evaluate the correctness of your work. Approach #1 is the “visual” approach: we compare our output to your output, and look for differences. Any differences (even spacing) is reported as incorrect. Approach #2 is the “unit test” approach: we call your functions with various parameters, and compare your function return values to the correct values. Any differences are flagged as incorrect. Approach #1 is used when we are checking complete programs for correctness; approach #2 is used when checking “units” of code such as your binarysearchtree class. What we’re going to focus on today is approach #2, “unit testing”. This is by far the most common form of testing in the software industry today.
Get Free Quote!
257 Experts Online