04+-+Testing+and+Function+Pointers (1)

04+-+Testing+and+Function+Pointers (1) - EECS 280...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Testing and Function Pointers EECS 280 Programming and Introductory Data Structures 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Five Steps in Testing To test some piece of code (either a component or a whole piece): 1. Understand the specification 2. Identify the required behaviors 3. Write specific tests 4. Know the answers in advance 5. Include stress tests 2
Background image of page 2
Five Steps in Testing 1. Understand the specification For an entire assignment, read through the specification very carefully, and make a note of everything it says you have to do – and stay away from the computer  Since you then have to break down the solution into its (smaller) constituent parts, you must write most of those specifications. This makes your job quite a bit harder, as there is no external source to tell you what is “supposed” to happen. 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Five Steps in Testing 2. Identify the required behaviors For any specification, it is possible to boil the specification down to a list of things that must and must not happen. These are the “required behaviors” and a correct implementation must exhibit all of them . Note that a required behavior is really a “class” of behaviors. For example, a program that adds two numbers only has one behavior – add the numbers correctly. The list of behaviors is not adding 1 and 1 4
Background image of page 4
Five Steps in Testing 3. Write specific tests For each of your required behaviors, write one or more test cases that check them. To the extent possible, the test case should check exactly one behavior – no more! That way, if the case fails, you know where to start looking. 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Five Steps in Testing 3. Write specific tests There are three classes of test cases that make sense: Simple inputs Boundary conditions Nonsense Simple cases are those that are “expected” or “normal” for the problem at hand. “Boundary” cases are at the edges of what is expected, or formed to exploit some detail of implementation. 6
Background image of page 6
Five Steps in Testing 4. Know the answers in advance Instead of quickly running test cases and glancing at the output: Write down what you expect a correct answer to be first. If the result differs in
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 26

04+-+Testing+and+Function+Pointers (1) - EECS 280...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online