Blackbox Testing and White Box Testing Notes
Blackbox Testing and White Box Testing Notes
Testing
Basis Path Testing
• Basis Path Testing is a white-box testing technique based on the control structure of a
program or a module.
• Using this structure, a control flow graph is prepared and the various possible paths
present in the graph are executed as a part of testing.
• Therefore, by definition, Basis path testing is a technique of selecting the paths in
the control flow graph, that provide a basis set of execution paths through the program
or module.
• Since this testing is based on the control structure of the program, it requires complete
knowledge of the program’s structure.
• To design test cases using this technique, four steps are followed :
1. Construct the Control Flow Graph
2. Compute the Cyclomatic Complexity of the Graph
3. Identify the Independent Paths
4. Design Test cases from Independent Paths
Basis Path Testing : Control Flow Graph
• Control Flow Graph – A control flow graph (or simply, flow graph)
is a directed graph which represents the control structure of a program
or module. A control flow graph (V, E) has V number of nodes/vertices
and E number of edges in it. A control graph can also have :
• Junction Node – a node with more than one arrow entering it.
• Decision Node – a node with more than one arrow leaving it.
• Region – area bounded by edges and nodes (area outside the graph is
also counted as a region.).
Basis Path Testing : Control Flow Graph
Basis Path Testing : Control Flow Graph
notation
Basis Path Testing : Control Flow Graph
Basis Path Testing : Control Flow Graph
Basis Path Testing : Control Flow Graph
• Independent Paths : An independent path in the control flow graph is the one which
introduces at least one new edge that has not been traversed before the path is defined.
• The cyclomatic complexity gives the number of independent paths present in a flow graph. This is
because the cyclomatic complexity is used as an upper-bound for the number of tests that should be
executed in order to make sure that all the statements in the program have been executed at least
once.
• Consider first graph given above here the independent paths would be 2 because number of
independent paths is equal to the cyclomatic complexity. So, the independent paths in above
first given graph :
Black Box Testing : Graph Based
Black Box Testing : Equivalence
• Equivalence partitioning is a black-box testing technique that allows testers to group input
data into sets or classes, making it possible to reduce the number of test cases while still
achieving comprehensive coverage. This technique is particularly useful when dealing
with a large range of input values. Let’s walk through an example to understand the
concept and process of Equivalence Partitioning.
• Testing a Login Form
• Suppose we have a login form with a username field. To apply Equivalence Partitioning,
we can divide the possible input values into equivalence classes based on their expected
behavior.
• Equivalence Classes:
• 1. Valid Usernames: Alphanumeric usernames with a length of 5 to 15 characters.
• 2. Invalid Usernames: Usernames containing special characters or exceeding the length
limit.
• 3. Empty Usernames: Leaving the username field empty.
Black Box Testing : Boundary Value Analysis
• Boundary values are those that contain the upper and lower limit of a variable. Assume that, age is
a variable of any function, and its minimum value is 18 and the maximum value is 30, both 18 and
30 will be considered as boundary values.
• The basic assumption of boundary value analysis is, the test cases that are created using boundary
values are most likely to cause an error.
• There is 18 and 30 are the boundary values that's why tester pays more attention to these values,
but this doesn't mean that the middle values like 19, 20, 21, 27, 29 are ignored. Test cases are
developed for each and every value of the range.
• Testing of boundary values is done by making valid and invalid partitions. Invalid partitions are
tested because testing of output in adverse condition is also essential.
• Imagine, there is a function that accepts a number between 18 to 30, where 18 is the minimum
and 30 is the maximum value of valid partition, the other values of this partition are 19, 20, 21,
22, 23, 24, 25, 26, 27, 28 and 29. The invalid partition consists of the numbers which are less
than 18 such as 12, 14, 15, 16 and 17, and more than 30 such as 31, 32, 34, 36 and 40. Tester
develops test cases for both valid and invalid partitions to capture the behavior of the system on
different input conditions.