Upload
oana-feidi
View
2.498
Download
6
Embed Size (px)
Citation preview
SOFTWARE QUALITY ASSURANCEWHITE BOX
Seminar: Oana FEIDIQuality Manager – Continental Automotive
White Box (Structural Testing) Structural - test case selection is based on an
analysis of the internal structure of component
Control flow Statement testing Branch/Decision Testing Branch Condition Testing Modified Condition Combination Testing
Data flow testing
White Box
Using the white-box testing techniques outlined in this seminar, a software engineer can design test cases that
exercise independent paths within a module or unit;
exercise logical decisions on both their true and false side;
execute loops at their boundaries and within their operational bounds
exercise internal data structures to ensure their validity
Statement testing
uses a model of the program’s control flow it is designed in order to execute all or selected statements of
the test object
An entity in a programming language which is typically
the smallest indivisible unit of execution.
Test cases are design to execute each statement.
For each test case specify:
• the input(s) of the component
• identification of statement(s) to be executed by the test case
• the expected outcome of the test case
Test completeness criteria: the percentage of the statements in the software which were executed at least at once (executing a statement means that the statement was encountered and evaluated during testing).
Example
float foo (int a, int b, int c, int d, float e) {
float e;if (a == 0) {
return 0;}int x = 0;if ((a==b) OR ((c == d) AND bug(a) )) {
x=1;}e = 1/x;return e;
}
statement
Branch/Decision Testing
uses a model of the program’s flow it is designed in order to execute (each) outcome
of all or selected decision points in a test object
an executable statement which may transfer control
to another statement, depending upon the logicof the decision statement
For each test specify:
• the input(s) of the component
• Identification of decision outcome(s) to be executed by the test case
• the expected outcome of the test case
Test completeness criteria: achievement of the test coverage – 100% of the branches (one true and one false for each part of condition)
Example
A = true and (B or C) = false A = false and (B or C) = true
Case A B C Output
1 0 1 1 0
2 1 0 0 0
if A and (B or C)
Branch Condition Combination uses a model of the program flow where each
combination of the inputs for a decision/condition must be tested, in order to check if each branch is covered
For each test case specify: the input(s) of the component the expected outcome of the test case which can show
which branch is covered
Test completeness criteria: for a condition containing n boolean operands → 2n test cases are required to achieve 100% coverage
Note: this coverage rapidly becomes unachievable for more complex conditions.
Example
Case A B C Outcome
Start
if a & (b or c)
End
true
false
A = true, false
B = true, false
C = true, false
Exercise !!!
White Box - summary
Statement testing uses a model of the program’s control flow it is designed in order to execute all or selected statements of the test object
Branch/Decision Testing uses a model of the program’s flow it is designed in order to execute (each) outcome of all or
selected decision points in a test object
Branch Condition Combination uses a model of the program flow where each
combination of the inputs for a decision/condition must be tested, in order to check if each branch is covered
Can we discover the mistake?
What happens if we have:IF(A AND (B AND C))
instead ofIF (A AND (B OR C))
Exercise: Verify if using Branch/Decision testing and Branch Condition Combination
testing we can discover the mistake.
Modified Condition Combination Testing
uses a model of the program’s flow where each atomic condition is independently tested, in order to show how the decision outcome is affected
test case are designed to show that each condition independently affects the decision outcome
For each test case specify: the input(s) of the component The expected outcome of the test case
Modified Condition Combination Testing
Test completeness criteria for a condition containing n boolean
operands, to achieve 100% coverage are necessary: minimum: n + 1 test cases maximum: 2n test cases
Example: for 3 boolean operands, to achieve 100% coverage are necessary:
Minimum 4 test cases Maximum 6 test cases
Example
Case A B B or C C Outcome
1 1 1 1 0 1
2 0 0
3 1 1 1 0 1
4 0 0 0
5 1 0 1 1 1
6 0 0 0
if (A and (B or C))
Loop Testing
Simple Loops:- 'n' is the maximum number of allowable passes
skip the loop entirely. only one pass thru the loop. two passes thru the loop. m passes thru the loop where m< n. n-1,n,n+1 passes thru the loop
Nested loops start with the innermost loop. Set all other loop to min. values. conduct simple loop tests for the innermost loop while holding
the outer loops at their min. iteration values. work outward, conducting tests for the next loop, but keeping
all the outer loops at their min. iteration count. continue until all loops have been tested.