Professional Documents
Culture Documents
Testing PDF
Testing PDF
Testing Testing is is the the process process of of executing executing a a program program with with the the intent intent of of finding finding errors. errors.
Glen Glen Myers Myers
Exhaustive testing
There are 10 14 possible paths! If we execute one test per millisecond, it would take 3.170 years to test this program!!
loop < 20x
BUT: Testing can only prove the presence of bugs - never their absence
the results are easy to see x distinct output is generated for each input x incorrect output is easily identified z
controllability
x x
z z z z
decomposability - software modules can be tested independently simplicity - no complex architecture and logic stability - few changes are requested during testing understandability - program is easy to understand
an indication of quality
Test cases
Describe how to test a system/module/function z Description must identify
z
y system
developer
Understands the system but, will test gently and, is driven by delivery
independent tester
Must learn about the system, but, will attempt to break it and, is driven by quality
state before executing the test to be tested y parameter values for the test y expected outcome of the test
y function
z z
function to be tested
y
function to be tested
y
ResourcePool = ResourcePool\anAgent
AgentNotFoundException is thrown
public methods
fulfilled
Why cover?
logic errors and incorrect assumptions are inversely proportional to a paths execution probability z we often believe that a path is not likely to be executed; in fact, reality is often counter intuitive z typographical errors are random; its likely that untested paths will contain some
z
Exhaustive testing
If-then-else
Selective testing
a selected path
First, we compute the cyclomatic complexity: number of simple decisions P +1 (compound predicates have to be split) number of enclosed areas +1
In this case, V (G) = 4 V(G) provides an upper bound of tests that must be executed to guarantee coverage of all program statements
Cyclomatic complexity
A number of industry studies have indicated that the higher V(G), the higher the probability of errors.
modules
Next, we derive the independent paths: Since V(G) = 4, there are four paths
Path 1:
4 5 3
Path 2:
6
Path 3: Path 4:
7
Loops
z z
Loop testing
simple loop
nested loops
concatenated loops
unstructured loops
Nested loops
Just extending simple loop testing: number of tests explodes z Reduce the number of tests:
z
y start
at the innermost loop; set all other loops to minimum values y conduct simple loop test; add out of range or excluded values y work outwards while keeping inner nested loops to typical values y continue until all loops have been tested
Example
abs(integer x) Return x if x >= 0 Return -x if x<0 z The concrete value of x does not matter!
Equivalence partitioning
Partitioning is based on input conditions
Range a..b
y test
output domain
Number of values:
y test
z z
Output bounds should be checked Boundaries of data structures shall be checked (e.g. arrays)
ECE 452 - Introduction to Software Engineering
Comparison testing
z z z
Safety critical systems Develop several implementations for a specification Run tests with all and compare results if not identical: investigate in detail Problems:
y expensive y errors y all