Introduction To Computers and Programming: - Goals of Testing - Classification
Introduction To Computers and Programming: - Goals of Testing - Classification
Programming
Prof. I. K. Lundqvist
Lecture 13
April 16 2004
Testing
• Goals of Testing
• Classification
– Test Coverage
– Test Technique
• Blackbox vs Whitebox
• Secondary Objectives
– Design tests that systematically uncover different
classes of errors
– Do so with a minimum of time and effort
– Provide reliable indications of software quality
Test Techniques 1
– Coverage-based testing
• Testing requirements are specified in terms of the
coverage of the product to be tested
– Fault-based testing
• Fault detecting ability of the test set determines
the adequacy
– Error-based testing
• Focus on error-prone points, based on knowledge
of the typical errors that people make
4
(Definitions)
• Error
– Error is a human action that produces an incorrect
result
• Fault
– Consequence of an error is software containing a
fault. A fault thus is the manifestion of an error
• Failure
– If encountered, a fault may result in a failure
PRS
1. Errors
2. Faults
3. Failures
4. I am still sleeping …
6
Test Techniques 2
Black-Box Testing
8
Black-Box Testing
Inputs causing
Inputs causing
anomalous
anomalous
Input test data I behavior
behaviour
e
System
Outputs
Outputswhich
which reveal
reveal
the presence of
Output test results O the presence of defects
Oe defects
Equivalence Partitioning
invalid
Invalidinputs
inputs valid inputs
Valid inputs
System
System
outputs
Outputs
11
Equivalence Partitioning
• Partition system inputs and outputs into
‘equivalence sets’
– If input is a 5-digit integer between 10,000 and
99,999 equivalence partitions are
• <10,000
• 10,000-99,999
• >99,999
12
Equivalence Partitions
3 11
4 7 10
Less than 10000 Between 10000 and 99999 More than 99999
Input values
Input values
13
Pre-Condition
-- the array has at least one element
T’First <= T’Last
Post-Condition
-- the element is found and is referenced by L
( Found and T(L) = Key)
or
-- the element is not in the array
( not Found and
not (Exists I, T’First >= I <= T’Last, T (I) = Key ))
14
Testing Guidelines (Sequences)
• Test software with sequences which
have only a single value
15
Test data
Tests Derives
Component Test
code outputs
17
Exhaustive Testing
22
Basis Set
• Basis set of execution paths = set of paths
that will execute all statements and all
conditions in a program at least once
23
Flow Graph Notation
1
2,3
1
6 R 4,5
2 2
7 R 8
3 R
1
3 9
4 R
6 4
10
5
7 8 11 m Node
9
Edge
10
Graph Cyclomatic Number V(G) = e - n + 1
11 R Region
i
Cyclomatic Complexity CV(G) = V(G) + 1
24
modules
CV(G)
modules in this range are
more error prone
26
CV(G) = 4
1
There are four paths
2
Path 1: 1,2,3,6,7,8
4 3 Path 2: 1,2,3,5,7,8
5 6 Path 3: 1,2,4,7,8
Path 4: 1,2,4,7,2…7,8
27
Selective Testing
28
Condition Testing
• Exercises each logical condition in a
program module
• Possible conditions:
– Simple condition:
• Boolean variable (T or F)
• Relational expression (a<b)
– Compound condition:
• Composed of several simple conditions
((a=b) and (c>d))
29
Condition Testing Methods
• Branch testing:
– Each branch of each condition needs to be
exercised at least once
• Domain testing:
– Relational expression a<b:
• 3 tests: a<b, a=b, a>b
– Boolean expression with n variables
• 2n tests required
30
Selective Testing
31
Loop Testing
Loop Testing
33
Testing Simple Loops
34
35
Testing Concatenated Loops
36
Bad Programming!
37
Selective Testing
38
Dataflow Testing
39