The article for today is about white box testing.I had written article about white box testing in this blog but that time it was only introduction of white box testing.This article concern with how to do white box testing.
The procedure of White box testing is normally saparated into 3 topic as follow
It is the testing to verify that all instructions or code must be executed at least one time.We can specify one or more than one test case for doing statement coverage testing (there may be a chance that one test case is not cover all the code we need to test).Below is an example demonstate how to do statement coverage testing.
Suppose you have a piece of code to test like this
If you determin ‘C’ as the test case then the coverage reach 100% (pass through all line of code) and only one test case is sufficient for doing Statement Coverage for this code.
Advantage of Statement Coverage.
1.To ensure that all source code can be reached at least for one time.
2.It is suitable for making Performance profiling because it can be applied directly to object code without processing source code.
Disadvantage of Statement Coverage.
1.It is insensitive to logical operators such as OR (||),AND (&&) etc.
2.If your source code have a lot of IF-ELSEIF-ELSE statements or contain consecutive switch labels then the test case used for doing Statement Coverage will be increased respectively.
2. Branch Coverage (Condition judgment Coverage)
It is the testing to verify that all branches and instructions must be executed at least one time (Concentrate on testing to cover every branches or decision points in the code).It is the easiest way to perform testing of path or workflow of program.
Please consider the code below and its explanation to understand the operation of Branch Coverage testing.
In the above code we need only two test case to cover all the branches (also all instructions too), they are…
Test case #1 : Input n1 = 1 , n2 = 1
Test case #2 : Input n1 = 2 , n2 = 0
Advantage of Branch Coverage.
1.To validate all branches in the code can be reached and ensure that no branches lead to abnormal of the program’s operation.
2.It eliminate problems that occur with Statement Coverage testing.
Disadvantage of Branch Coverage.
1.There may be other condition that can be used for decision making.For the example, statement “if((b == TRUE) || functionA())”, in this statement we can define only test case with “B = TRUE” and this test case is cover this branch but functionA() isn’t tested.
3.Condition Coverage/Multiple Condition Coverage
It is the testing to verify that all condition expression within each branch will be tested (the true and the false condition of each sub-expression within the decision branch must be tested at least one time ).
It is more intensive testing than Branch Coverage and Statement Coverage.Multiple Condition Coverage has detail of testing more than Condition Coverage.Its test cases are larger than test case of Condition
Coverage because it ensures that all possible combination of conditions of sub-expression within each branch must be tested.
Please consider the code below for Condition Coverage testing.
If you want to test above code by using Condition Coverage you must specify two test
cases to cover all sub-expressions in this branch.The test cases are as follow…
Test case #1: Input n1 = 60 , n2 = 70
Test case #2: Input n1 = 40 , n2 = 110
If you want to test above code with Multiple Condition Coverage you must specify four
test cases to cover all combination of possible condition of sub-expressions in this branch and the test cases look like these
Test case #1: Input n1 = 60 , n2 = 70
Test case #2: Input n1 = 60 , n2 = 110
Test case #3: Input n1 = 40 , n2 = 70
Test case #4: Input n1 = 40 , n2 = 110
Advantage of Condition/Multiple Condition coverage.
1.It is very thorough testing and the bugs are normally found by this kind of testing.
1.If the decision branch contain lots of sub-expressions or has very complex boolean expressions , the tester will have to define a large number of test cases.
White Box testing
Another name of White box testing is Glass-Box testing or Structural Testing.
It is the test in the system.The tester have to specify the test case that will be used
for test the system.They must have an ability in programming and well understand in
software testing theory.Their task it to assign the test case to every line, every
statement or every path of the program being tested. You can compare white box
testing with the measurement of electronics circuit (In measurement of electronics
circuit,you have to measure the electric current and voltage in every node existing
in your circuit).
White box testing can be applied for testing in Unit testing,Integration testing
or System testing but in commonly the tester apply White box testing in Unit testing phase
of software development.
The advantage of White box testing.
1.The process of White box testing can increase te quality of source code and can make
the pieces of source code work more efficiency because it is the testing in the system
(In the function and in every branches of the code)
2.In White box testing we can look for an error by give an input to the system and monitor
the output from the system.Otherwise it also can look for the internal error that existing
in the mentioned system too.
The disadvantage of White box testing.
1.This kind of testing require high skill in software coding to assure the high-quality of
Black Box testing.
Another name of Black-Box testing is Functional Testing.It is the testing
that disregard internal mechanism of the system (don’t test the internal component
of the system such as source code or function).This testing method is focus on the
output that come out from the system after we sent the input to it (Output that
come out after the system responded to the input data).
In Black-Box Testing, the tester will not look for the code to test, so the code
is considered to be “Black Box” that we can’t see the content inside the box.The
tester know only they must send the input to the “Black Box” and then it will release
the output to the tester.
The tester usually use the requirement specification document (Requirement
Knowledge) to build the test case, so they know what is the outcome that the system
will send after they send the corresponding input to it.
Now I can summarize the black box testing as follow…
– It is the testing that disregard the source code or command
in the program.
– It is testing of function of system base on the requirement documents.
– The tester must assume for output that will come out from the system
after sending the various input pattern to the system (The output must match up with
Now I can summarize White Box Testing as follow…
-It is the testing that examine the structure or the work-flow of the program .
-The tester must build the specific test case used for testing in each specific condition.
-The test case must contain the case that can be executed normally and abnormally.
-Try to execute every statement in the function at least 1 time.
In the next article I will write about Test first method (Software testing part III).
You can see more information about Black box and White box testing at these websites below
1.Software Testing Fundamentals
2.Testing and Code Coverage
Reference site: lenovoblogs