16/27/2015 3:38 am6/27/2015 3:38 am6/27/2015 3:38 amtesting and debugging testing the process of...

11
1 03/17/22 03/17/22 02:44 02:44 Testing and Debugging Testing and Debugging Testing Testing The process of verifying the software The process of verifying the software performs to the specifications. performs to the specifications. The developer executes the program The developer executes the program with a selected subset of all with a selected subset of all possible input, and compares the possible input, and compares the actual output with the expected actual output with the expected output. output. Ideally planned during unit design Ideally planned during unit design and coding – will help with and coding – will help with development. development.

Post on 21-Dec-2015

228 views

Category:

Documents


0 download

TRANSCRIPT

1104/18/2304/18/23 21:5421:54 Testing and DebuggingTesting and Debugging

TestingTesting

The process of verifying the software The process of verifying the software performs to the specifications.performs to the specifications.

The developer executes the program with The developer executes the program with a selected subset of all possible input, and a selected subset of all possible input, and compares the actual output with the compares the actual output with the expected output.expected output.

Ideally planned during unit design and Ideally planned during unit design and coding – will help with development.coding – will help with development.

2204/18/2304/18/23 21:5421:54 Testing and DebuggingTesting and Debugging

DebuggingDebugging

The process of fixing errors that are found The process of fixing errors that are found in the software during testing.in the software during testing.

A software error is also called a “bug in the A software error is also called a “bug in the system” – from an incident in the early system” – from an incident in the early history of computers when a moth became history of computers when a moth became stuck in a electrical switch in a computer stuck in a electrical switch in a computer causing it to malfunction.causing it to malfunction.

3304/18/2304/18/23 21:5421:54 Testing and DebuggingTesting and Debugging

Development Life CycleDevelopment Life Cycle

Unit Testing: testing the functionality of an Unit Testing: testing the functionality of an individual program.individual program.

System Testing: testing the system as a whole.System Testing: testing the system as a whole.

Acceptance Testing: the users of the system try Acceptance Testing: the users of the system try it to verify it performs as expected.it to verify it performs as expected.

Regression Testing: after changes are made to Regression Testing: after changes are made to the system, it is retested to verify untouched the system, it is retested to verify untouched functionality still performs properly.functionality still performs properly.

4404/18/2304/18/23 21:5421:54 Testing and DebuggingTesting and Debugging

Black Box TestingBlack Box Testing

““Black Box” is a concept from engineering.Black Box” is a concept from engineering.

A device of some type has a specification A device of some type has a specification for what it is to do and an interface. How it for what it is to do and an interface. How it does it is unknown.does it is unknown.

Black box testing is testing Black box testing is testing whatwhat a a program to verify it performs to the program to verify it performs to the specificationspecification..

5504/18/2304/18/23 21:5421:54 Testing and DebuggingTesting and Debugging

White Box TestingWhite Box Testing

Testing a device knowing how it is Testing a device knowing how it is implemented internally.implemented internally.

Clear Box Testing may be a better name Clear Box Testing may be a better name because the tester can see the internals.because the tester can see the internals.

White box testing is testing White box testing is testing howhow the the software software implementationimplementation accomplishes accomplishes its function.its function.

6604/18/2304/18/23 21:5421:54 Testing and DebuggingTesting and Debugging

White Box TestingWhite Box Testing

Many different theories and methods.Many different theories and methods.

Full testing: entering all possible inputs and Full testing: entering all possible inputs and verifying the output is correct – not feasible for verifying the output is correct – not feasible for all but the most trivial programs.all but the most trivial programs.

A commonly accepted method: use input data A commonly accepted method: use input data that will execute all operations (lines of code) in that will execute all operations (lines of code) in the program at least once. This will also test all the program at least once. This will also test all logic branches in the program. If the output from logic branches in the program. If the output from these tests is correct, the program is probably these tests is correct, the program is probably correct (but not guaranteed).correct (but not guaranteed).

7704/18/2304/18/23 21:5421:54 Testing and DebuggingTesting and Debugging

Logic Control StructuresLogic Control Structures

If: both conditions should be tested (true If: both conditions should be tested (true and false) for each part of || operator.and false) for each part of || operator.

While: the loop should be executed zero, While: the loop should be executed zero, once, and more than once.once, and more than once.

Off-By-One Errors: conditions should be Off-By-One Errors: conditions should be tested at the limit and just beyond the limit.tested at the limit and just beyond the limit.

8804/18/2304/18/23 21:5421:54 Testing and DebuggingTesting and Debugging

Stubs & DriversStubs & Drivers

Stub: a null function to hold the place of the real function Stub: a null function to hold the place of the real function until the real function has been developed. Used to until the real function has been developed. Used to continue development without having to wait for the continue development without having to wait for the function to be developed. Used for system testing from function to be developed. Used for system testing from the top down.the top down.Driver: a program to read in test data and call the Driver: a program to read in test data and call the function to be tested and then record the output of that function to be tested and then record the output of that function. The test data and the results can be saved to function. The test data and the results can be saved to verify testing was done correctly. Also testing can be verify testing was done correctly. Also testing can be repeated easily as often as needed. Used for unit testing repeated easily as often as needed. Used for unit testing or function testing from the bottom up.or function testing from the bottom up.

9904/18/2304/18/23 21:5421:54 Testing and DebuggingTesting and Debugging

ToolsTools

Diagnostic Outputs: lines of code added that output the values of Diagnostic Outputs: lines of code added that output the values of selected variables at key points in the program to verify the program selected variables at key points in the program to verify the program works the way it should (remove them for the final version of the works the way it should (remove them for the final version of the program).program).Asserts:Asserts:

A line of code added that verifies selected conditions exist.A line of code added that verifies selected conditions exist. Format: assert(<condition>); // #include <cassert>Format: assert(<condition>); // #include <cassert> If condition is false when line executes, the program stops with an error.If condition is false when line executes, the program stops with an error.

Debugger: a software tool (part of the IDE). It will display the code Debugger: a software tool (part of the IDE). It will display the code as it is executing. Variables can be displayed and the flow of control as it is executing. Variables can be displayed and the flow of control can be monitored.can be monitored.Profiler: a software tool. It will produce a printout of the code with Profiler: a software tool. It will produce a printout of the code with either the run-time or the execution count next to each line.either the run-time or the execution count next to each line.

101004/18/2304/18/23 21:5421:54 Testing and DebuggingTesting and Debugging

EngineeringEngineering

Desk Checking: visually examining (reading) the Desk Checking: visually examining (reading) the code to look for errors or ways to improve the code to look for errors or ways to improve the program.program.

Code Reviews: several peers desk check the Code Reviews: several peers desk check the program, then meet to discuss the results and program, then meet to discuss the results and any possible actions to be taken.any possible actions to be taken.

Design Reviews: the unit or system design is Design Reviews: the unit or system design is desk checked by several peers to verify the desk checked by several peers to verify the design meets requirements.design meets requirements.

111104/18/2304/18/23 21:5421:54 Testing and DebuggingTesting and Debugging

ReadingReading

Sections 5.9 & 6.5 cover these same Sections 5.9 & 6.5 cover these same concepts. Reviewing them may help clarify concepts. Reviewing them may help clarify the material.the material.