QA Techniques: White Box Testing

Krisnawan Hartanto
Software Testing Pipeline
4 min readNov 3, 2022

--

This article is a continuation of the QA technique series. To read previous articles in the same series, you are welcome to follow the link below.

If in the previous article I wrote about black box testing, in this article I will write about white box testing,

White box testing

What is White Box Testing?

White box testing is a software testing method that takes advantage of an internal view of the software code.

It is called a ‘white box’ because you can see inside an application’s source code and observe the way it is put together. With white box testing, test data enters the system via parameters, variables, and stored procedures and exits through return codes and stored procedures. This allows you to follow logic paths through the system as well as error-handling paths.

White Box Testing Techniques

White box testing is a technique that allows you to test your code at the source level. This means that you can test every line of code in a module or class. It also means that you can test the relationships between different modules and classes.

White box testing techniques include statement coverage, branch coverage, condition coverage, basis path testing, graph notation, Cyclomatic Complexity, and loop testing.

Statement coverage

Statement Coverage is the most basic and fundamental test coverage technique.

It focuses on testing all individual statements in a program at least once. Thus every node in the flowchart is tested.

Although this may seem trivial, it helps to achieve 100% statement test coverage. Because of this, it’s often considered a minimum requirement for any level of testing.

Branch Coverage

Branch Coverage ensures that the test for every possible path (if-else and loops) has been executed at least once by running all combinations of boolean expressions.

The idea behind branch coverage is that each decision condition should be tested with both true and false values; covering these branches is an important step toward achieving full branch coverage.

Branch coverage may also be referred to as condition-decision coverage or decision-branch coverage.

Condition Coverage

Condition Coverage ensures that every conditional statement has been evaluated at least once by running through all possible combinations of boolean expressions.

For example, there are conditions; X<0 and Y>0. Then we’ll have 4 possible conditions; TRUE and TRUE, TRUE and FALSE, FALSE and TRUE, and FALSE and FALSE.

Basis Path Testing

Basis path testing is a method that allows test case designers to make measurements of the logical complexity of the procedural design and use these measurements as a guide for defining the basis set of execution paths.

Test cases created to test the basis set are guaranteed to execute every statement in the program at least once during testing

Flow graph notation

This technique uses a directed graph to identify all possible paths and then maps those paths to create tests for them.

The graph is consist of nodes, decision nodes, junction nodes, and edges, and each node represents a sequence or decision point.

Cyclomatic Complexity

Cyclomatic complexity is used to determine the number of paths that need to be searched.

Cyclomatic complexity is a software metric that provides a quantitative measure of the logical complexity of a program. The value calculated for cyclomatic complexity determines the number of independent paths in the base set of a program and provides the minimum number of tests that must be performed to ensure that all statements have been executed at least once.

Loop testing

This test is mandatory to test various loops in the program, such as do-while, for, and while. In this test, you can also check the condition of the loop, whether it is running correctly or not.

Advantages of White Box Testing

  1. White box testing is very thorough so it can increase accuracy in implementing software.
  2. Makes it easy to find errors or bugs in software that were not previously seen.
  3. Can be executed early so that it can detect bugs early.
  4. Facilitates testing because it is carried out thoroughly so as to minimize the possibility of errors in the code.

Disadvantages of White Box Testing

  1. Quite complex.
  2. Hard to maintain, because if there is any changes in the code, we need to rewrite the testcase.
  3. Consumes a lot of resources because White-box testing is a fairly expensive test.
  4. Expensive.

Conclusion

So, we already talk about White Box Testing, as a part of the Testing Technique series. We already talk about the definition of white-box testing, the technique of white-box testing, also the advantages and disadvantages of white-box testing.

I hope we can learn something new every day.

Connect with me

Krisnawan: Twitter | Linkedin | Medium

MydoQA: Twitter | Blog | Instagram | Facebook

Resources

--

--