What is testing?

Download Report

Transcript What is testing?

INTRUDUCTION TO
SOFTWARE TESTING
TECHNIQUES
BY
PRADEEP I
TESTING THE SOFTWARE
What is it?
Who does it?
When is it done?
How is it done?
What is software?
It is
• Instructions when executed provide desired
function and performance
• Data structures that enable the programs to
adequately manipulate information and
• Documents that describe the operation and
use of the programs
What is testing?
• Testing is a process of executing a program
with the intention of finding an error
• A good test case is one that has a high
probability of finding an as-yet-undiscovered
error
• A successful test is one that uncovers an asyet-undiscovered error
Who does it?
• During early stages of testing, software
engineer performs all tests.
• As the testing process progresses testing
specialists will get involved.
When is it performed?
• Testing does not start at the end of software
process.
• It is performed throughout the software
process.
• Test case design and test planning can begin
as soon as requirement analysis is completed.
How is it performed?
It is performed in two perspectives.
1. Internal program logic is exercised using
white box testing.
2. Software requirements are exercised using
black box testing.
White box testing
• Guarantees that all independent paths within
a module have been exercised at least once.
• Exercises all logical decisions on their true
and false sides
• execute all loops at their boundaries and
within their operational bounds.
• Exercise internal data structures to ensure
their validity.
Basis path testing
1. Using the design or code as foundation,
draw a corresponding flow graph.
2. Determine the cyclomatic complexity of the
resultant flow graph. The cyclomatic
complexity V(G) is provides an upper bound for
the number of tests required to ensure that all
statements have been executed at least once. It is
V(G) = 6 regions
V(G) = 17 edges - 13 nodes = 6
V(G) = 5 predicate nodes + 1= 6
3. Determine a basis set of linearly
independent paths. The value of V(G) provides
the number of linearly independent paths through
the program control structure.
Path 1: 1-2-10-11-13
Path 2: 1-2-10-12-13
Path 3: 1-2-3-10-11-13
Path 4: 1-2-3-4-5-8-9-2-….
Path 5: 1-2-3-4-5-6-8-9-2-….
Path 6: 1-2-3-4-5-6-7-8-9-2-….
4. Prepare test cases that will force execution
of each path in the basis set. Data should be
chosen so that conditions at the predicate nodes
are appropriately set as each path is tested.
Path 1 test case:
value[k] = valid input, where k< i for 2  i  100
value[i] = -999 where 2  i  100
Expected results: correct average based on k
values and proper totals.
Note: path 1 can not be tested stand alone. It must
be tested as part of path 4,5 and 6.
Path 2 test case:
value[1] = -999
Expected results: average = -999, other totals at
initial values.
Path 3 test case:
Attempt to process 101 or more values.
First 100 values should be valid.
Expected results: correct average based on 100
inputs and proper totals.
Path 4 test case:
value[i] = valid input where i < 100
value[k] < minimum where k < I
Expected results: correct average based on k values
and proper totals.
Path 5 test case:
value[i] = valid input where i < 100
value[k] > maximum where k < i
Expected results: Correct average based on k values
and proper totals.
Path 6 test case:
value[i] = valid input where i < 100
Expected results: Correct average based on given
values and proper totals.
5. Each test case is executed and compared to
expected results.
PRECEDURE average;
* This procedure computes the average of 100 or fewer numbers that
lie between bounding values ;
it also computes the sum and the total number valid.
INTERFACE RETURNS average, total.input, total.valid;
INTERFACE ACCEPTS value, minimum, maximum;
TYPE value[1:100] IS SCALAR ARRAY;
TYPE average, total.input, total.valid,
minimum, maximum, sum IS SCALAR;
TYPE i IS INTEGER;
Contd...
i = 1;
2
3
total.input
=
total.valid
=
sum
=
0;
1
DO WHILE value[i] <> -999 AND total.input < 100
6
increment total.input by 1;
4
IF value[i] >= minimum AND value[i] <= maximum
5
THEN increment total.valid by 1;
7
sum = sum + value[i];
ELSE skip;
8 ENDIF
increment i by 1;
9 ENDDO
10
IF total.valid > 0
11 THEN average = sum / total.valid;
12
ELSE average = -999;
13 ENDIF
END average
No. of nodes = 13
No. of edges = 17
No. of regions = 6
No. of predicate
nodes = 5
1
Flow graph for
procedure average
2
R1
4
10
12
R2
3
R6
R5
5
11
R3 6
R4
13
8
9
7
Loop testing
To test simple loops with a maximum of n passes
• Skip the loop entirely.
• Only one pass through the loop.
• Two passes through the loop.
• m passes through the loop where m < n.
• n-1, n, n+1 passes through the loop.
To test nested loops
• Start at the innermost loop. Set all other
loops to minimum values.
• Conduct simple loop tests for the innermost
loop.
• Work outward, conducting tests for the next
loop.
• Continue until all loops have been tested.
Black box testing
It attempts to find out the errors in the
following categories.
• Incorrect or missing functions.
• Interface errors.
• Errors in data structures or external data
base access.
• Behavior or performance errors.
• Initialization and termination errors.
Equivalence partitioning
• Divide the input domain into classes of data.
• If input constraints to range, define one valid
class and two invalid classes.
• If input constraints to member of a set, define
one valid one invalid class.
• If inputs condition is boolean, define one
valid and one invalid class.
Boundary value analysis
• If input is a range specified by a and b, test
with values a, b, and just below and above a
and b.
• Apply above guideline to output conditions.
• If internal program data structures have
prescribed boundaries, then exercise the data
structure at its boundary.
Testing documentation
Documentation should provide
• Accurate description of how to accomplish
each mode of use.
• Accurate description of each interaction
sequence.
• Accurate examples.
• Terminology, menu description and system
responses that are consistent with actual
program.
• Easy access to locate guidance with in the
document.
• Description of troubleshooting.
• Accurate and complete table of contents and
index.
• Accurate and complete hyper links.
• Easy navigation for information.
• Good design. (indentation, typefaces, layout,
graphics, etc.)
Is this the end?
Testing never ends. It just gets transferred
from from us to our customer. Every time
the customer uses the program, a test is
being conducted.
Our aim of testing is to discover and correct
the maximum possible number of errors
before the “customer’s tests” begin.