stmmod2
stmmod2
Black Box Testing is also known as It is also known as structural testing, clear box
functional testing, data-driven testing, testing, code-based testing, and transparent
and closed-box testing. testing.
It is not well suitable for algorithm It is well suitable and recommended for algorithm
testing. testing.
The base of this testing is external The base of this testing is coding which is
expectations. responsible for internal working.
It is less exhaustive than White Box testing. It is more exhaustive than Black Box testing.
In black-box testing, there is no In white-box testing, there is a requirement of
implementation knowledge is required. implementation knowledge.
It can be performed by trial and error It can test data domain and data boundaries in
technique. a better way.
S1) Start S5 S2
In the table when the user enters the correct PIN, state is transitioned to S5 which is Access
granted. And if the user enters a wrong password he is moved to next state. If he does the
same 3rd time, he will reach the account blocked state.
Decision Table Based Testing in Software Testing
What is a Decision Table :
Decision tables are used in various engineering fields to represent complex logical
relationships. This testing is a very effective tool in testing the software and its requirements
management. The output may be dependent on many input conditions and decision tables
give a tabular view of various combinations of input conditions and these conditions are in
the form of True(T) and False(F). Also, it provides a set of conditions and its corresponding
actions required in the testing.
Parts of Decision Tables :
In software testing, the decision table has 4 parts which are divided into portions and are
given below :
1. Condition Stubs : The conditions are listed in this first upper left part of the decision
table that is used to determine a particular action or set of actions.
2. Action Stubs : All the possible actions are given in the first lower left portion (i.e,
below condition stub) of the decision table.
3. Condition Entries : In the condition entry, the values are inputted in the upper right
portion of the decision table. In the condition entries part of the table, there are
multiple rows and columns which are known as Rule.
4. Action Entries : In the action entry, every entry has some associated action or set of
actions in the lower right portion of the decision table and these values are called
outputs.
Types of Decision Tables :
The decision tables are categorized into two types and these are given below:
1. Limited Entry : In the limited entry decision tables, the condition entries are
restricted to binary values.
2. Extended Entry : In the extended entry decision table, the condition entries have
more than two values. The decision tables use multiple conditions where a condition
may have many possibilities instead of only ‘true’ and ‘false’ are known as extended
entry decision tables.
Example 1: How to make Decision Base Table for Login Screen
Let’s create a decision table for a login screen.
The condition is simple if the user provides the correct username and password the user will
be redirected to the homepage. If any of the input is wrong, an error message will be
displayed.
Username (T/F) F T F
Password (T/F) F F T
Output (E/H) E E E
Legend:
T – Correct username/password
F – Wrong username/password
E – Error message is displayed
H – Home screen is displayed
Interpretation:
Case 1 – Username and password both were wrong. The user is shown an error
message.
Case 2 – Username was correct, but the password was wrong. The user is shown an
error message.
Case 3 – Username was wrong, but the password was correct. The user is shown an
error message.
Case 4 – Username and password both were correct, and the user navigated to the
homepage
Let’s convert this control flow graph into a graph matrix. Since the graph has 4 nodes, so the
graph matrix would have a dimension of 4 X 4. Matrix entries will be filled as follows :
(1, 1) will be filled with ‘a’ as an edge exists from node 1 to node 1
(1, 2) will be filled with ‘b’ as an edge exists from node 1 to node 2. It is important to
note that (2, 1) will not be filled as the edge is unidirectional and not bidirectional
(1, 3) will be filled with ‘c’ as edge c exists from node 1 to node 3
(2, 4) will be filled with ‘d’ as edge exists from node 2 to node 4
(3, 4) will be filled with ‘e’ as an edge exists from node 3 to node 4
The graph matrix formed is shown below :
Connection Matrix :
A connection matrix is a matrix defined with edges weight. In simple form, when a
connection exists between two nodes of control flow graph, then the edge weight is 1,
otherwise, it is 0. However, 0 is not usually entered in the matrix cells to reduce the
complexity.
For example, if we represent the above control flow graph as a connection matrix, then the
result would be :
As we can see, the weight of the edges are simply replaced by 1 and the cells which were
empty before are left as it is, i.e., representing 0.
A connection matrix is used to find the cyclomatic complexity of the control graph.
Although there are three other methods to find the cyclomatic complexity but this method
works well too.
Following are the steps to compute the cyclomatic complexity :
1. Count the number of 1s in each row and write it in the end of the row
2. Subtract 1 from this count for each row (Ignore the row if its count is 0)
3. Add the count of each row calculated previously
4. Add 1 to this total count
5. The final sum in Step 4 is the cyclomatic complexity of the control flow graph
Let’s apply these steps to the graph above to compute the cyclomatic complexity.
We can verify this value for cyclomatic complexity using other methods :
Method-1 :
Cyclomatic complexity
=e-n+2*P
Since here,
e=5
n=4
and, P = 1
Therefore, cyclomatic complexity,
=5-4+2*1
=3
Method-2 :
Cyclomatic complexity
=d+P
Here,
d=2
and, P = 1
Therefore, cyclomatic complexity,
=2+1
=3
Data flow testing makes use of control flow graphs and associations.
Types of Data Flow Testing
1. Static Data Flow Testing
Declaring the variables, using the variables, and finding the values all happen without the
code execution is static data flow testing. Control flow graphs are used for the same.
2. Dynamic Data Flow Testing
The variables and their value are examined with the code execution in dynamic data flow
testing. The changes in the variable and their references are observed with the requirement
that the code must be executed.
Associations
Here associations are made between, where the variable is defined and used. The format of
the association is as follows: (line variable declared, line variable used, variable name).
1. int(x)
2. if(x%2==0)
3. x=x+10
4. else
5. x=x+5
Associations of the above code are as follows:
(1,(2,t),x) for the true condition in line 2 (1,(2,f),x) for the false condition in line 2 (1,3,x) for
the x being used in line 3 (1,5,x) for the x being used in line 5
There are two types of uses of variables based on how they are being used in the code.
Predicate use: This value decides the flow of the code, as in line 2 is called p-
use. Computational use: The variable's value is used by another variable, so if we have z=x in
line 6. That would be a c-use.
Advantages of Data Flow Testing
1. Data flow testing helps to redefine the flow of code.
2. It helps to identify the excess code if it exists.
3. It helps to identify computational variables.
4. It tests the code without executing it.
Disadvantages of Data Flow Testing
1. Since it is white box testing, coding knowledge is required.
2. It is a time-consuming testing process.
3. It requires a good amount of manual testing.
4. It is a slow process as a lot of manual intervention is required.
Data Flow Testing Coverage
1. All definition coverage: It covers all the sub-paths from each definition.
2. All definition-c use coverage: It covers all the computation use sub-paths from each
definition
3. All definition-p use coverage: It covers all the predicate use sub-paths from each
definition
4. All-use coverage: It covers all the c-use and p-use sub-paths from each definition.
5. All definition use coverage: It covers all the sub-paths from definition to their
respective use.
If (x>y) If(x<y)
Print “Hello” Print “Hello”
Else Else
Print “Hi” Print “Hi”