WhiteBoxTesting

WhiteBoxTesting - White Box Testing Sources: Code Complete,...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
White Box Testing Sources: Code Complete, 2 nd Ed., Steve McConnell Software Engineering, 5 th Ed., Roger Pressman
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
White Box Testing From a testing perspective, looking at the class's internal implementation, in addition to its inputs and expected outputs, enables you to test it more thoroughly Testing that is based both on expected external behavior and knowledge of internal implementation is called "white box testing"
Background image of page 2
White Box Testing White box testing is primarily used during unit testing Unit testing is usually performed by the engineer who wrote the code In rare cases an independent tester might do unit testing on your code
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Complete Path Coverage Test ALL possible paths through a subroutine Example What test cases are needed to achieve complete path coverage of this subroutine? Some paths may be impossible to achieve. Skip those paths Often there are too many paths to test them all, especially if there are loops in the code. In this case, we use less complete approaches: Line coverage Branch coverage Condition testing Loop testing
Background image of page 4
Line coverage At a minimum, every line of code should be executed by at least one test case Example What test cases are needed to achieve complete line coverage of this subroutine? Developers tend to significantly overestimate the level of line coverage achieved by their tests Coverage tools (like Cobertura) are important for getting a realistic sense of how completely your tests cover the code Complete line coverage is necessary, but not sufficient
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Branch coverage Similar to line coverage, but stronger Test every branch in all possible directions If statements test both positive and negative directions Switch statements test every branch If no default case, test a value that doesn't match any case Loop statements test for both 0 and > 0 iterations
Background image of page 6
Branch coverage Example What test cases are needed to achieve complete branch coverage of this subroutine? Why isn't branch coverage the same thing as line coverage?
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Branch coverage Example What test cases are needed to achieve complete branch coverage of this subroutine? Why isn't branch coverage the same thing as code coverage? Consider an if with no else, or a switch with no default case Line coverage can be achieved without achieving branch coverage
Background image of page 8
Complete Condition testing For each compound condition, C Find the simple sub-expressions that make up C Suppose there are n of them
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/02/2012 for the course C S 340 taught by Professor Woodfield,s during the Winter '08 term at BYU.

Page1 / 25

WhiteBoxTesting - White Box Testing Sources: Code Complete,...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online