{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

04+-+Testing+and+Function+Pointers

04+-+Testing+and+Function+Pointers - Five Steps in Testing...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
5/6/2009 1 Testing and Function Pointers Ve 280 Programming and Introductory Data Structures Five Steps in Testing y To test some piece of code (either a component or a whole piece): 1. Understand the specification 2 Id if h i d b h i 2. Identify the required behaviors 3. Write specific tests 4. Know the answers in advance 5. Include stress tests Five Steps in Testing 1. Understand the specification y 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 y Since you then have to break down the solution into its (smaller) constituent parts, you must write most of those specifications. y This makes your job quite a bit harder, as there is no external source to tell you what is “supposed” to happen. y Sometimes your program as a whole may not work correctly because your specification is incorrect (e.g. you misunderstood the definition of standard deviation). Five Steps in Testing 2. Identify the required behaviors y For any specification, it is possible to boil the specification down to a list of things that must and must not happen. y These are the “required behaviors” and a correct implementation must exhibit all of them . y Note that a required behavior is really a “class” of behaviors. y For example, a program that adds two numbers only has one behavior – add the numbers correctly. y The list of behaviors is not adding 1 and 1 and getting 2, adding 1 and 2 and getting 3, etc… y Try this for project 1. For example, what happens if a payment is less than 0? Five Steps in Testing 3. Write specific tests y For each of your required behaviors, write one or more test cases that check them. y To the extent possible, the test case should check exactly one behavior no more! one behavior – no more! y That way, if the case fails, you know where to start looking. Five Steps in Testing 3. Write specific tests y There are three classes of test cases that make sense: y Simple inputs y Boundary conditions y Nonsense y Simple cases are those that are “expected” or “normal” for the problem at hand. y “Boundary” cases are at the edges of what is expected, or formed to exploit some detail of implementation. y “Nonsense” cases are those that are clearly unexpected. y What are examples of these cases for project 1?
Image of page 1

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

View Full Document Right Arrow Icon
5/6/2009 2 Five Steps in Testing 4. Know the answers in advance y Instead of quickly running test cases and glancing at the output: y Write down what you expect a correct answer to be first. y If the result differs in any way from what you expected, try to figure out why to figure out why.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern