White-Box Testing - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

White-Box Testing

Description:

White-Box Testing Pfleeger, S. Software Engineering Theory and Practice 2nd Edition. Prentice Hall, 2001. Ghezzi, C. et al., Fundamentals of Software Engineering. – PowerPoint PPT presentation

Number of Views:167
Avg rating:3.0/5.0
Slides: 25
Provided by: SteveR199
Category:
Tags: box | pfleeger | testing | white

less

Transcript and Presenter's Notes

Title: White-Box Testing


1
White-Box Testing
  • Pfleeger, S. Software Engineering Theory and
    Practice 2nd Edition. Prentice Hall, 2001.
  • Ghezzi, C. et al., Fundamentals of Software
    Engineering. Prentice Hall, 2002.
  • Pressman, R., Software Engineering A
    Practitioners Approach, Mc Graw Hill, 2005.

1209
2
White Box Testing
  • Also known as
  • Glass box testing
  • Structural testing
  • Test set is derived from structure of code
  • Code structure represented as a Control Flow
    Graph
  • Goal is to cover the CFG

3
Control Flow Graphs
  • Programs are made of three kinds of statements

4
Control Flow Graph (CFG)
Sequence
If-then-else
Iterative
If-then
5
Example 1 CFG
1. read (result) 2. read (x,k) 3. while
result lt 0 then 4. ptr ? false 5. if x gt k
then 6. ptr ? true 7. x ? x 1 8.
result ? result 1 9. print result
6
Write a CFG
  • Example 2
  • 1. if (a lt b) then
  • 2. while (a lt n)
  • 3. a ? a 1
  • 4. else
  • 5. while (b lt n)
  • 6. b ? b 1

7
Answers
  • Example 3
  • 1. read (a,b)
  • 2. if (a ? 0 b ? 0) then
  • 3. c ? a b
  • 4. if c gt 10 then
  • 5. c ? max
  • else c ? min
  • 7. else print Done

8
Answers
  • Example 4
  • 1. read (a,b)
  • 2. if (a ? 0 b ? 0) then
  • 3. c ? a b
  • 4. while( c lt 100)
  • 5. c ? a b
  • 6. c ? a b

9
Cyclomatic Complexity
  • Software metric for the logical complexity of a
    program.
  • Defines the number of independent paths in the
    basis set of a program
  • Provides the upper bound for the number of tests
    that must be conducted to ensure that all
    statements been have executed at least once
  • For Edges (E) and Nodes (N)
  • V(G) E N 2

10
Complexity of CFGs
3,4
3,4
1
1
5
5
6
2
Join
Join
3
11
Example
1
2,3
6
4,5
8
7
9
10
11
12
Example 1 CFG
1,2
3
9
4,5
6
Join
7,8
13
Example 2
14
Answers
15
Answers
16
Criteria
  • Statement coverage
  • Branch coverage
  • Condition coverage
  • (lots of others )

17
Branch Coverage
  • Each edge of a programs CFG is traversed at
    least once in some test.
  • Independent paths
  • 1, 2, 3, 9
  • 1, 2, 3, 4, 5, 6, 7, 8, 3, , 9
  • 1, 2, 3, 4, 5, 7, 8, 3, , 9

Example 1
18
Criteria
  • Statement coverage
  • Branch coverage
  • Condition coverage
  • Every complex condition is made true and false by
    every possible combination
  • E.G., (x and y)
  • x true, y true
  • xfalse, ytrue
  • x true, y false
  • x false, y false

19
AND Condition
1, 2A
2B
4
3
Join
20
OR Condition
1,2A
3
2B
4
5
Join
21
Path Coverage-1
  • Every distinct path through code is executed at
    least once
  • Basis set does not yield minimal test set
  • Example
  • 1. read (x)
  • 2. read (z)
  • 3. if x ? 0 then begin
  • 4. y ? x z
  • 5. x ? z end
  • 6. else print Invalid
  • 7. if y gt 1 then
  • 8. print y
  • 9. else print Invalid
  • Test Paths
  • 1, 2, 3, 4, 5, J1, 7, 8, J2
  • 1, 2, 3, 4, 5, J1, 7, 9, J2
  • 1, 2, 3, 6, J1, 7, 8, J2,
  • 1, 2, 3, 6, J1, 7, 9, J2

1,2,3
4,5
6
Join1
7
8
9
Join2
22
Def-Use Coverage
  • Def-use coverage every path from every
    definition of every variable to every use of that
    definition is exercised in some test.
  • Example
  • 1. read (x)
  • 2. read (z)
  • 3. if x ? 0 then begin
  • 4. y ? x z
  • 5. x ? z end
  • 6. else print Invalid
  • 7. if y gt 1 then
  • 8. print y
  • 9. else print Invalid

Def x, z Use x
1,2,3
4,5
Def y, x Use x, z
6
Use none
Join
7
Use y
8
Use none
9
Use y
  • Test Path 1, 2, 3, 4, 5, 7, 8, J

Join
23
Strength of Coverage
24
What paths dont tell you
  • Timing errors
  • Unanticipated error conditions
  • User interface inconsistency (or anything else)
  • Configuration errors
  • Capacity errors
Write a Comment
User Comments (0)
About PowerShow.com