Professional Documents
Culture Documents
4 White Box Testing
4 White Box Testing
4 White Box Testing
Nagarro Public 2
What is White Box Testing?
• White Box Testing is a software testing technique
whereby explicit knowledge of the internal
workings of the item being tested are used to
select the test data.
Nagarro Public 4
White Box Testing - Focus
Nagarro Public 5
Black Box Vs. White Box Testing
Nagarro Public 6
What are my other names?
Nagarro Public 7
What are my other names?
• Structural Testing
• Code-Based Testing
Nagarro Public 8
Diff Types of White Box Testing
• Statement Coverage
• Branch/Decision Coverage
• Path Coverage
• Mutation testing
Nagarro Public 9
Statement Coverage
• Example:
READ P, Q
IF P+Q > 100 THEN
PRINT 'LARGE'
END IF
IF P>50
PRINT 'P Is Greater'
END IF
Nagarro Public 10
Statement Coverage ..contd
Nagarro Public 11
Statement coverage …contd
• P=60, Q=45
• P+Q=105, P>60
• Statement Coverage=(7/7)*100=100 %
• We need just 1 TC for 100% Statement Coverage
• P=45, Q=60
• P+Q=105, P<60
• Statement Coverage=(6/7)*100=86 % (approx)
Nagarro Public 12
Branch/Decision Coverage
• It is an outcome of a decision, & measures the no
of decision outcomes or branches, which have
been tested.
Nagarro Public 13
Branch/Decision Coverage …contd
• Example:
READ P, Q
IF P+Q > 100 THEN
PRINT 'LARGE'
END IF
IF P>50
PRINT 'P Is Greater'
END IF
Nagarro Public 14
Branch/Decision Coverage contd…
Nagarro Public 15
Branch/Decision Coverage contd…
• P=60, Q=45
• P+Q=105, P>60
• First branch is covered
• P=40, Q=50
• P+Q=90 and not > 100, P not > 50
• Second branch is also covered
Nagarro Public 17
Path Coverage contd…
• Example:
READ P, Q
IF P+Q > 100 THEN
PRINT 'LARGE'
END IF
IF P>50
PRINT 'P Is Greater'
END IF
Nagarro Public 18
Path Coverage contd…
Nagarro Public 19
Path Coverage contd…
Test case1:
• P=60, Q=45
• P+Q=105>100 & P>50
Test Case2:
• P=40, Q=70
• P+Q>100 but P<50
Nagarro Public 20
Path Coverage contd…
Test Case3:
• P=60, Q=30
• P+Q<100 but P>50
Test Case4:
• P=40, Q=50
• P+Q=90<100 & P<50
Nagarro Public 21
Path Coverage - Cyclomatic Complexity
Nagarro Public 22
Cyclomatic Complexity - How to calculate
• Edge-Node+2
Nagarro Public 23
Mutation Testing
Nagarro Public 24
Mutation Testing – Benefits
Nagarro Public 25
Mutation Testing – How to apply
Nagarro Public 26
Mutation Testing – Example
• Given
if (a && b) {
c = 1;
} else {
c = 0;
}
Nagarro Public 27
Mutation Testing – Mutation Operators
• Statement deletion.
• Replace each boolean subexpression with true and false.
• Replace each arithmetic operation with another one, e.g. + with *, -
and /.
• Replace each boolean relation with another one,
e.g. > with >=, == and <=.
• Replace each variable with another variable declared in the same
scope (variable types should be the same).
Nagarro Public 28
White Box Testing - Advantages
Nagarro Public 29
White Box Testing - Disadvantages
Nagarro Public 30
Thank You
www.nagarro.com