lec10

lec10 - CSE 8A: Lecture 10 Software testing: stubs and...

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

View Full Document Right Arrow Icon
Page 1 of 39 CSE 8A, UCSD LEC 10 CSE 8A: Lecture 10 Software testing: stubs and drivers Tracing for debugging More on static vs. instance variables and methods (Reading: Savitch, Ch. 4 and 5)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Page 2 of 39 CSE 8A, UCSD LEC 10 Software testing Remember the 3 kinds of bugs: syntax errors, runtime errors, logic errors The compiler finds the first of these, but the other two require program testing to track down and fix Some rules of software testing: Test every function in your program Test every path of execution in every function (every branch of every if-else) To attain “full-coverage” testing like this, you need to test on a variety of well- selected input data
Background image of page 2
Page 3 of 39 CSE 8A, UCSD LEC 10 Stubs, drivers and top-down design Recall the idea of “top-down”, “stepwise refinement” design: Start with a problem, decompose it into subproblems, decompose them into sub- subproblems, etc. Each subproblem is solved by writing a class or a method that is called by methods at a “higher” level, and that calls methods at a “lower” level Every class and method should ultimately be tested in the context of the entire working system. But the pieces should be tested separately first. How to do that? You can use “bottom-up” testing, or “top-down” testing, or a combination of both
Background image of page 3

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

View Full DocumentRight Arrow Icon
Page 4 of 39 CSE 8A, UCSD LEC 10 Bottom-up and Top-down testing “Bottom-up” testing of a method: write a test driver that will exercise the method, putting it through its paces in a simulation of how it might be used in the final working software system called “bottom-up testing” because it is assumed that everything “below” the method being tested -- i.e., all method that this method calls -- have already been tested “Top-down” testing of a method: The method calls other methods, which have not been written yet. So, write stubs : methods which have the return type, name, and type of arguments of the real methods which will be called, but that don’t do much (maybe just return a value or print a simple message) for testing purposes called “top-down testing” because it is assumed that everything “above” the method being tested -- i.e., all methods that call this method -- have already been tested Keep in mind that both bottom-up and top-down testing are used in the testing phase; top-down design is used in the design phase
Background image of page 4
Page 5 of 39 CSE 8A, UCSD LEC 10 Tracing and debugging When trying to track down logic or runtime errors in your program, it is helpful to look at the values of variables in your program as it is running this is called tracing the variables A debugger is a program that lets you trace variables jdb is the standard JDK Java debugger. .. but it is not very easy to use other development environments for Java may provide nice debuggers But instead of using a debugger program, you can always place statements in your program to print out the values of variables when debugging
Background image of page 5

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

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

Page1 / 39

lec10 - CSE 8A: Lecture 10 Software testing: stubs and...

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

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