Upload
oana-feidi
View
10.968
Download
0
Tags:
Embed Size (px)
Citation preview
SOFTWARE QUALITY ASSURANCEWHITE BOX
Seminar: Oana FEIDIQuality Manager – Continental Automotive
BLACK-BOX VS. WHITE-BOX
Test cases derived from specifications
The focus is not the design, nor the implementation The focus is on the logic of implementation
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).
EXAMPLEfloat 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.
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
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.
EXERCISE
1) Identify what scenarios have to be run to achieve 100% statement coverage and 100% branch coverage on the following code
2) Test the same examples on the following link. Does white-box covers 100% the black-box?