White Box Testing:
This is also known as Structural Testing, Glass Box Testing, Clear Box Testing
Transparent Box Testing. Contrast with Black Box Testing.
White box testing is the detailed investigation of internal logic and structure of the code. White box testing is also called glass testing or open box testing. White box testing intends to execute code and test statements, branches, path, decisions and data flow within the program being tested. In order to perform white box testing on an application, the tester needs to possess knowledge of the internal working of the code. The tester needs to have a look inside the source code and find out which unit/chunk of the code is behaving inappropriately.
White-box testing and Black-box testing complement each other as each of the testing approaches has potential to un-cover specific category of errors.
Cyclomatic or Cyclometric or Conditional Complexity
This is software metric to express the complexity of the source code. There is a tight correlation between a program’s cyclomatic complexity and its maintainability and testability. Hence when the cyclomatic complexity is higher, the probability of errors when refactoring or enhancing or fixing the source code is higher.
This technique is used in white-box testing. The complexity number is the minimum number of test cases required to cover all the flows of the program. It also helps in deciding to split/modularize the complex program. Generally the acceptable maximum complexity is 15.
Cyclomatic Complexity = E – N + 2P
E – Number of Edges/Paths of the Graph (conditional statements)
N – Number of Nodes of the graph (return statements)
P – Number of Connected Components (number of programs)
For e.g., Consider 1 program having if-then, for-next, do-while and switch-cases.
E = Total Number of “if (including elseif)” in the program + Total Number of “loops” from “For-Next” + Total Number of “loops” from “Do-While” + Total Number of Cases (ignore default case) in the “Switch-Case”
N = Total Number of “Return” operators
P = Number of Programs = 1 in this case.
Hence Cyclomatic Complexity = E – N + 2P = (if’s + loops + cases) – (returns) + 2 * 1
|Cyclomatic Complexity||Risk Evaluation|
|1-10||A simple module without much risk|
|11-20||A more complex module with moderate risk|
|21-50||A complex module of high risk|
|51 and greater||An untestable program of very high risk|
Scripted end-to-end testing that duplicates specific workflows which are expected to be utilized by the end-user.