Академический Документы
Профессиональный Документы
Культура Документы
Structural Testing
Introduction General Concepts
Flow Graph Testing
DD-Paths
Test Coverage Metrics
Basis Path Testing
Guidelines and Observations
Data Flow Testing
Hybrid Methods
Retrospective on Structural Testing
1
CA267 Ray Walshe 2015
An Overview of Path Testing
Coverage Criteria
Basic Measures
Statement Coverage
Decision Coverage
Condition Coverage
Multiple Condition Coverage
Condition/Decision Coverage
Modified Condition/Decision Coverage
Path Coverage
Other Measures
Function Coverage
Call Coverage
Loop Coverage
2
CA267 Ray Walshe 2015
Coverage Analysis
The objectives of coverage analysis are:
To determine gaps in test cases (i.e. parts of the program that are not
tested)
To establish a quantitative measure for the testing efficiency
To identify additional tests that may be needed to eliminate gaps
3
CA267 Ray Walshe 2015
Coverage Analysis and Test Plans
A good test plan utilizing coverage analysis must:
4
CA267 Ray Walshe 2015
Statement Coverage
The measure reports on the percentage of executable
statements of the code exercised by a set of test cases. Also
known as basic bloc coverage or segment coverage.
Statement coverage requires in most cases very few test cases to achieve.
Not acceptable to release code based on statement coverage alone.
7
CA267 Ray Walshe 2015
Decision Coverage
Decision coverage (also known as branch coverage, all-edges coverage,
basis path coverage, decision-decision-path testing) reports whether
boolean expressions in control structures are evaluated to both true and
false values by the test cases.
8
CA267 Ray Walshe 2015
Decision Coverage Examples
if(A) if (A && (B || F1()))
F1(); F2();
else else
F2(); F3();
if(B)
F3() Test Cases for Decision Coverage:
else A=T, B=T
F4(); A=F
Problem: F1() never gets called. This
Test Cases for Decision Coverage: problem occurs in languages with
A=T, B=T short circuiting boolean operators
A=F, B=F
9
CA267 Ray Walshe 2015
Decision Coverage Comments
This measure has the advantage of simplicity
without the problems of statement coverage.
10
CA267 Ray Walshe 2015
Condition Coverage
Condition coverage reports the true or false outcome of each boolean
sub-expression.
11
CA267 Ray Walshe 2015
Condition Coverage Examples
if(A && B) if(A && B)
F1(); F1();
else else
F2(); F2();
if(C) if(C)
F3() F3()
else else
F4(); F4();
Test Cases for Condition Coverage: Test Cases for Condition Coverage:
A=T, B=T, C=F A=T, B=F, C=F
A=F, B=F, C=T A=F, B=T, C=T
Problem: decision coverage not achieved
12
CA267 Ray Walshe 2015
Multiple Condition Coverage
13
CA267 Ray Walshe 2015
Multiple Condition Coverage Examples
if(A && B) // condition 1
F1();
else
F2();
if(C || D)// condition 2
F3()
else
F4();
The short circuit logical operators in C, C++ and Java only evaluate
conditions when their result can affect the encompassing decision.
16
CA267 Ray Walshe 2015
Modified MCC Examples
To test if (A or B)
A: T F F
B: F T F
To test if (A and B)
A: F T T
B: T F T
To test if (A xor B)
A: T T F
B: T F T
17
CA267 Ray Walshe 2015
Path Coverage
This measure reports whether each of the possible paths in each function
have been followed. A path is a unique sequence of branches from the
function entry to the exit. This measure is also known as predicate
coverage.
18
CA267 Ray Walshe 2015
Path Coverage Examples
if (A) A
Paths:
F1(); A-F1-F2-A-F3-F4
F2(); A-F2-A-F3-F4
F1
if (A) A-F1-F2-A-F4
F3(); A-F2-A-F4
F2
F4();
Problem: only two
A are feasible
A=T
A=F
F3
19
CA267 Ray Walshe 2015 F4
Path Coverage Comments
Path coverage has the advantage of requiring very thorough
testing.
Path coverage has two severe disadvantages.
21
CA267 Ray Walshe 2015
Function Coverage
This measure reports whether each function
or procedure in the program has been
invoked.
23
CA267 Ray Walshe 2015
Coverage Measures Comparison
Relative strengths when a stronger measure includes
a weaker measure.
Decision coverage includes statement coverage since
exercising every branch must lead to exercising every
statement.
Condition/decision coverage includes decision coverage
and condition coverage (by definition).
Path coverage includes decision coverage.
Predicate coverage (paths as possible combinations of
logical conditions) includes path coverage and multiple
condition coverage, as well as most other measures.
24
CA267 Ray Walshe 2015
Testing Strategy (1)
Your highest level of testing productivity occurs when we
identify the most failures with the least effort.
Notice we do not require 100% coverage in any of the initial goals. This
allows us to defer testing the most difficult areas and maintain high
testing productivity; by achieving maximum results with minimum effort
[1]
26
Source:
CA267 Ray Walshehttp://www.bullseye.com/coverage.html
2015 [1]
Testing Productivity