Chapter 21. Control-Flow Testing
In this chapter, I cover some basics related to white-box testing of the control-flows in units. By control flows in units, I mean the sequence of execution of statements. In many cases, one statement follows the previous statement. However, in some cases the sequencing of statements is determined by decisions. Some of these decisions are made in branches like if statements and switch statements. Some of these decisions are made in loops like for statements and while statements and function calls.
Control-flow-based white-box testing is the cheapest way to find many types of coding bugs because many bugs are errors in control flows that exist entirely within a line or a few lines of a unit. Why wait until you have a “needle in a haystack” situation, where bugs lurk among millions of lines of code during system test? Early white-box unit testing by programmers can greatly increase the quality of the system and reduce the costs of poor quality later in the project.
If you are a tester, you might not find this section applicable to your daily work. However, I encourage you to skim this chapter and Chapter 23, on data-flow-based white-box testing. A basic familiarity with good unit testing practices can help you have an intelligent conversation with your programmer colleagues and assess the unit test coverage.
If you are a programmer, you’ll find this chapter and the next two chapters helpful. The example programs run on either Windows or Linux systems ...
Get Pragmatic Software Testing: Becoming an Effective and Efficient Test Professional now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.