15
SOFTWARE QUALITY ASSURANCE WHITE BOX Seminar: Oana FEIDI Quality Manager – Continental Automotive

Whitebox

Embed Size (px)

Citation preview

Page 1: Whitebox

SOFTWARE QUALITY ASSURANCEWHITE BOX

Seminar: Oana FEIDIQuality Manager – Continental Automotive

Page 2: Whitebox

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

Page 3: Whitebox

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

Page 4: Whitebox

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).

Page 5: Whitebox

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

Page 6: Whitebox

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)

Page 7: Whitebox

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)

Page 8: Whitebox

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.

Page 9: Whitebox

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 !!!

Page 10: Whitebox

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

Page 11: Whitebox

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.

Page 12: Whitebox

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

Page 13: Whitebox

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

Page 14: Whitebox

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))

Page 15: Whitebox

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.