Author - StudySection Post Views - 1,714 views
White Box

Statement and Decision Coverage in White Box Testing

The structure of the system’s software is the basis for white-box testing. It’s most often used at the component level (so-called unit testing), but it can also be performed at any other test level utilizing the various white-box models of the system.

For instance,

  • At the integration level, call graphs
  • At the system level, business processes
  • At the acceptance testing level, menu structures

Characteristics of White Box Testing:

The following are some of the most common characteristics of white-box testing techniques:

  • A test basis, which may comprise code, software architecture, detailed design, or any other source of information about the software’s structure, is used to generate test conditions, test cases, and test data.
  • The items tested within a given structure (e.g., the code or interfaces) are used to determine coverage.
  • Specifications are frequently used as a secondary data source when determining the expected outcome of test cases.

Statement Coverage Testing in White Box Testing:

White box test cases are developed using the statement coverage technique. This process requires running all of the source code statements at least once. It is used to determine the total number of executed statements in the source code based on the total number of statements in the source code.
Statement coverage = No of statements Executed / Total no of statements in the source code * 100
Read A
Read B
if A>B
Print “A is greater than B”
else Print "B is greater than A"
Set1 :If A =5, B =2
No of statements Executed: 5
Total number of statements in the source code: 7
Statement coverage =5/7*100 = 71.00 %
Set2 :If A =2, B =5
No of statements Executed: 6
Total number of statements in the source code: 7
Statement coverage =6/7*100 = 85.20 %

This is purely a white-box method of testing. It examines the software’s internal coding and infrastructure, and it is the programmer’s responsibility to do so. This method is ideal for programmers.

Decision Coverage Testing in White Box Testing:

Decision coverage, also known as branch coverage, is a testing technique that ensures that each possible branch from each decision point is tested at least once, ensuring that all reachable code is executed.
That is to imply, every decision is made in both true and false forms. It aids in verifying all of the code’s branches, ensuring that none of them lead to abnormal application behavior.


In the diagram above, we have three decision points—these are the nodes: (1, 2), (3), and (6). Each of them has two outgoing transitions; hence altogether, we have six test conditions to cover:

  • Decision (1, 2) outcome to TRUE
  • Decision (1, 2) outcome to FALSE
  • Decision (3) outcome to TRUE
  • Decision (3) outcome to FALSE
  • Decision (6) outcome to TRUE
  • Decision (6) outcome to FALSE

The minimum number of test cases achieving the decision coverage is 3.

  • Test 1: 1, 2, 9, 10 (covers the test condition 2)
  • Test 2: 1, 2, 3, 4, 5, 3, 6, 7, 9, 10 (covers the test conditions 1, 3, 4, and 5)
  • Test 3: 1, 2, 3, 6, 8, 9, 10 (covers the test conditions 1, 4, and 6)

The minimal number of test cases, in this case, is 3, because number two of the test conditions 2, 5, and 6 can be exercised in one test case. Notice that we were able to cover both the test conditions 3 and 4 in one test case, taking advantage of the fact that there is a loop in the code, so we will cover the test condition 3, return, and then, within the next loop iteration, we cover the test condition 4.

If you have skills in PHP programming and you want to enhance your career in this field, a PHP certification from StudySection can help you reach your desired goals. Both beginner level and expert level PHP Certification Exams are offered by StudySection along with other programming certification exams.

Leave a Reply

Your email address will not be published.