Software Testing�a Innovative Perception
Dr.Somnath Thigale
Head & Associate Professor - CSE Dept.
Innovation Ambassador
Chapter 2 :Types Of Testing
White-box testing
White-box test design techniques
Classification of White Box Testing
Static Testing
Advantages Of Static Testing
Disadvantages Of Static Testing
Static Testing
1) Walkthrough�2) Inspection�3) Technical Review
Walkthrough�
Goals Of Walkthrough
Structured Walkthrough Participants:�
Benefits of Structured Walkthrough �
Inspection�
Goals of Inspection
Technical Review�
Goals of technical review
Difference between walkthrough and inspection
Inspection | Walkthrough |
Formal | Informal |
Initiated by the project team | Initiated by the author |
Planned meeting with fixed roles assigned to all the members involved | Unplanned. |
Reader reads the product code. Everyone inspects it and comes up with defects. | Author reads the product code and his team mate comes up with defects or suggestions |
Recorder records the defects | Author makes a note of defects and suggestions offered by team mate |
Moderator has a role in making sure that the discussions proceed on the productive lines | Informal, so there is no moderator |
Structural Testing
Code Functional Testing
Control Flow Graph
N1, N2, N3, N4 and N5 represents Basic Blocks or Nodes and E1, E2, E3, E4 and E5 represents Edges. We can also observe that N2, N3, N4 and N5 together represent an IF loop.
Statement Coverage:
Here all the statements in the program can be covered using two flow
But using these two statements the flow from N3 to N4 is not tested i.e. E4. It does not provide branch coverage. N3 has 2 exit points depending upon the decision statement in N3 i.e. True and False, but since N4 has already been covered, the testing for a decision statement is missed out.
Branch Coverage:�
In this case, the 100% branch coverage can be provided as following
But as we can see edge E1 can be tested for multiple conditions, but under branch testing the aim is to just test the edge for one condition and not for multiple conditions associated to it. The different conditions can be:
Condition Coverage:�
S.No. | A | B | A or B |
1 | 0 | 0 | 0 |
2 | 0 | 1 | 1 |
3 | 1 | 0 | 1 |
4 | 1 | 1 | 1 |
However when compound conditions are involved the no. of test cases may increase exponentially, which is not desired.
Modified Condition/Decision coverage:
Path Coverage:�
[Cyclomatic Complexity is quantitative measure of no. of linearly independent paths through a program and is used to indicate complexity of a program].
So, cyclomatic complexity helps aiming to test all linearly independent paths in a program at least once. These were some of the test coverage under this Testing.
Cyclomatic complexity is a software metric used to measure the complexity of a program.
This metric measures independent paths through the program's source code. An independent path is defined as a path that has at least one edge which has not been traversed before in any other paths.
Cyclomatic complexity can be calculated with respect to functions, modules, methods or classes within a program.
IF a OR b
then procedure x
else procedure y
ENDIF
insertion_procedure (int a[], int p [], int N)
02. {
03. int i,j,k;
04. for (i=0; i<=N; i++) p[i] = i;
05. for (i=2; i<=N; i++)
06. {
07. k = p[i];
08. j = 1;
09. while (a[p[j-1]] > a[k]) {p[j] = p[j-1]; j--}
10. p[j] = k;
11. }
12. }
01.insertion_procedure (int a[], int p [], int N)
02. {
03. (1) Int i,j,k;
04. (2) for ((2a)i=0; (2b)i<=N; (2c)i++)
05. (3) p[i] = i;
06. (4) for ((4a)i=2; (4b)i<=N; (4c)i++)
07. {
08. (5) k=p[i];j=1;
09. (6) while (a[p[j-1]] > a[k]) {
10. (7) p[j] = p[j-1];
11. (8) j--
12. }
13. (9) p[j] = k;
14. }
Now, to calculate the cyclomatic complexity you use one of three methods:
McCabe’s Cyclomatic Complexity
Mathematically, the cyclomatic complexity of a structured program is defined with reference to the control flow graph of the program, a directed graph containing the basic blocks of the program, with an edge between two basic blocks if control may pass from the first to the second. The complexity CC is then defined as
CC= E − N + 2P,
where
E = the number of edges of the graph.
N = the number of nodes of the graph.
P = the number of connected components.
The graph is strongly connected, and the cyclomatic complexity of the program is equal to the cyclomatic number of its graph which is defined as
CC = E − N + P.
For a single program (or subroutine or method), P is always equal to 1. So a simpler formula for a single subroutine is
CC = E − N + 2
Or it can be defined as
CC=D+1
Where D=Number of decision points in the graph
Flow graph notation for a program:
Example :
i = 0;
n=4; //N-Number of nodes present in the graph
while (i<n-1) do
j = i + 1;
while (j<n) do
if A[i]<A[j] then
swap(A[i], A[j]);
end do;
i=i+1;
end do;
Flow graph for this program will be
Computing mathematically,
CC = 9 - 7 + 2 = 4
CC= 3 + 1 = 4 (Condition nodes are 1,2 and 3 nodes)
Basis Set - A set of possible execution path of a program
1, 7
1, 2, 6, 1, 7
1, 2, 3, 4, 5, 2, 6, 1, 7
1, 2, 3, 5, 2, 6, 1, 7
Example :
Advantages of Structural Testing:�
Disadvantages of Structural Testing:�
Black Box Testing
This method attempts to find errors in the following categories:
EXAMPLE :
A tester, without knowledge of the internal structures of a website, tests the web pages by using a browser; providing inputs (clicks, keystrokes) and verifying the outputs against the expected outcome.
BLACK BOX TESTING ADVANTAGES
BLACK BOX TESTING DISADVANTAGES
Techniques For Black Box Testing
1.Requirement Based Testing
2.Positive & Negative Testing
3.Boundry Value Analysis
4.Decision Tables
5. Equivalence Partitioning
6.User Documentation Testing
7.Graph Based Testing
1.Requirement Based Testing�
Stages in Requirements based Testing:
Defining Test Completion Criteria - Testing is completed only when all the functional and non-functional testing is complete.
Design Test Cases - A Test case has five parameters namely the initial state or precondition, data setup, the inputs, expected outcomes and actual outcomes.
Execute Tests - Execute the test cases against the system under test and document the results.
Verify Test Results - Verify if the expected and actual results match each other.
Verify Test Coverage - Verify if the tests cover both functional and non-functional aspects of the requirement.
Track and Manage Defects - Any defects detected during the testing process goes through the defect life cycle and are tracked to resolution. Defect Statistics are maintained which will give us the overall status of the project.
2.Positive & Negative Testing�
Example of Positive testing:�
Negative Testing is testing process where the system validated against the invalid input data. A negative test checks if a application behaves as expected with its negative inputs.
The main reason behind Negative testing is to check the stability of the software application against the influences of different variety of incorrect validation data set.
It should show a validation error message for all invalid inputs or system should not allow to enter a non integer values.
Positive & Negative Testing Scenarios�
Positive Testing Scenario
Negative Testing Scenario
3.Boundry Value Analysis�
Example Of BVA
Test cases for the application whose input box accepts numbers between 1-1000. Valid range 1-1000, Invalid range 0 and Invalid range 1001 or more.
4.Decision Tables�
Way to use decision tables in test designing
Let’s take an example of a finance application, where users pay money – monthly Repayment or year wise (the term of loan). If user chooses both options, the system will create a negotiation between two. So, there are two conditions of the loan amount, mention in the given below table,
TABLE 1: Blank decision table
Conditions | Step 1 | Step 2 | Step 3 | Step 4 |
Repayment money has�been mentioned |
|
|
|
|
Terms of loan has been mentioned |
|
|
|
|
Next, recognize all of the combinations in “Yes” and “No” (In Table 2). In each column of two conditions mention “Yes” or “No”, user will get here four combinations (two to the power of the number of things to be combined). Note, if user has three things to combine, they will have eight combinations, with four things, there are 16, etc. Because of this, it’s always good to take small sets of combinations at once. To keep track on combinations, give alternate “Yes” and “No” on the bottom row, put two “Yes” and then two “No” on the row above the bottom row, etc., so the top row will have all “Yes” and then all “No” (Apply the same principle to all such tables).
Conditions | Step 1 | Step 2 | Step 3 | Step 4 |
Repayment money has�been mentioned | Y | Y | N | N |
Terms of loan has been mentioned | Y | N | Y | N |
TABLE 2: Decision table – Input combination
�
In the next step, recognize the exact outcome for each combination (In Table 3). In this example, user can enter one or both of the two fields. Each combination is sometimes referred to as a step.
TABLE 3: Decision table – Combinations and outcomes
Conditions | Step 1 | Step 2 | Step 3 | Step 4 |
Repayment money has�been mentioned | Y | Y | N | N |
Terms of loan has been mentioned | Y | N | Y | N |
Actions/Outcomes |
| |||
Process loan money | Y | Y |
|
|
Process term | Y |
| Y |
|
At this time you didn’t think that what will happen when customer don’t enter anything in either of the two fields. The table has shown a combination that was not given in the specification for this example. This combination can result as an error message, so it is necessary to add another action (In Table 4). This will flash the strength this method to find out omissions and ambiguities in specifications.
TABLE 4: Decision table – Additional outcomes
Conditions | Step 1 | Step 2 | Step 3 | Step 4 |
Repayment money has�been mentioned | Y | Y | N | N |
Terms of loan has been mentioned | Y | N | Y | N |
Actions/Outcomes |
| |||
Process loan money | Y | Y |
|
|
Process term | Y |
| Y |
|
Error message |
|
|
| Y |
We will provide you some other example that allows the customer to enter both repayment and term. This will change the outcome of our table, this will generate an error message if both are entered
TABLE 5: Decision table – Changed outcomes
Conditions | Step 1 | Step 2 | Step 3 | Step 4 |
Repayment money has�been mentioned | Y | Y | N | N |
Terms of loan has been mentioned | Y | N | Y | N |
Actions/Outcomes |
| |||
Process loan money |
| Y |
|
|
Process term |
|
| Y |
|
Error message | Y |
|
| Y |
The final process of this method is to write test cases to use each of the four steps in our table.
Conditions Rule 1 Rule 2 Rule 3 Rule 4�Repayment amount has Y Y N N�been entered:�Term of loan has been Y N Y N�entered:
Actions/Outcomes:�Result: Error Process loan Process Error�message amount term message message
Advantage of decision table technique:
Credit card example:�Let’s take another example. If you are a new customer and you want to open a credit card account then there are three conditions first you will get a 15% discount on all your purchases today, second if you are an existing customer and you hold a loyalty card, you get a 10% discount and third if you have a coupon, you can get 20% off today (but it can’t be used with the ‘new customer’ discount). Discount amounts are added, if applicable. This is shown in Table
5. Equivalence Partitioning�
Let us consider a program that separates integers into positive or negative. And accepts any number between -5 and + 5.
Valid | Valid | Valid | Invalid | Invalid |
-5 -1 | 0 | 1 5 | > 5 | < -5 |
The range of input integers can be split into the following partitions :
6.User Documentation Testing
BENEFITS
7.Graph Based Testing�
1. Employee desires leave
2. He applies leave application form
3. HR verify eligibility for leave
4. If it is eligible manager ensures feasibility
If it is feasible manager approve leave
If it is not feasible manager rejects leave
5.If it is not eligible HR rejects leave