21-Testing Strategies and Types of Testing, Test Plan-09-03-2024
21-Testing Strategies and Types of Testing, Test Plan-09-03-2024
Verification
Strategic Approach to Software Testing, Testing Fundamentals Test Plan, Test Design, Test
Execution, Reviews, Inspection and Auditing – Regression Testing – Mutation Testing -
Object oriented testing - Testing Web based System - Mobile App testing – Mobile test
Automation and tools – DevOps Testing – Cloud and Big Data Testing
Software Testing
What Testing shows
Strategic Approach
• To perform effective testing, you should conduct effective technical
reviews. By doing this, many errors will be eliminated before testing
commences
• Testing begins at the component level and works "outward" toward
the integration of the entire computer based system
• Different testing techniques are appropriate for different software
engineering approaches and at different points in time
• Testing is conducted by the developer of the software and (for large
projects) an independent test group
• Testing and debugging are different activities, but debugging must be
accommodated in any testing strategy
Any testing strategy must incorporate
• Test planning,
• Test case design,
• Test execution,
• Resultant data collection, and
• Evaluation
Validation and Verification
• Verification refers to the set of tasks that ensure that software
correctly implements a specific function.
• For OO Software
• Our focus when “testing in the small” changes from an individual module (the
conventional view) to an OO class that encompasses attributes and operations
and implies communication and collaboration.
Unit Testing
Unit Testing considerations
Unit Test procedures
Integration Testing Strategies
Top Down Integration
Bottom-Up Integration
Sandwich Testing
Regression Testing
• Regression testing is the re-execution of some subset of tests that have already
been conducted to ensure that changes have not propagated unintended side
effects
• Regression testing helps to ensure that changes (due to testing or for other
reasons) do not introduce unintended behavior or additional errors.
• Test case design draws on conventional methods, but also encompasses special
features
OO Testing Strategy
• class testing is the equivalent of unit testing
• operations within the class are tested
• the state behavior of the class is examined
• Integration applied three different strategies
• thread-based testing—integrates the set of classes required to
respond to one input or event
• use-based testing—integrates the set of classes required to
respond to one use case
• cluster testing—integrates the set of classes required to
demonstrate one collaboration
WebApp Testing - I
• The content model for the WebApp is reviewed to uncover errors.
• The interface model is reviewed to ensure that all use cases can be
accommodated.
• To identify hidden defects that can’t be detected using other testing methods.
• In this type of testing the values are changed to detect errors in the program.
white-box black-box
methods methods
Methods
Strategies
Unit
Integration
system
29
White-Box Testing
30
Traditional White Box Testing
• White box testing is further divided into 2 types
- Flow Graph
- Cyclomatic Complexity
- Graph Matrix
• Control Structure
- Condition Testing
- Loop Testing
32
33
Flow Chart
34
Flow Graph
35
36
37
38
1. Basis Path Testing
Module given for testing -> Flowchart -> Flow graph
Cyclomatic complexity = Edges-Nodes+2 (9-7+2 = 4)
= no. of Predictive nodes + 1 (3+1 = 4)
= No. of Closed path +1 (3+1=4)
or
39
Basis Path Testing
40
What is the complexity V(G)?
public void howComplex()
{
int i=20;
while (i<10)
{
System.out.printf("i is %d", i);
if (i%2 == 0)
{
System.out.println("even");
} else
{
System.out.println("odd");
}
i--;
}
}
V(G) = 2 decisions + 1 = 3
42
Convert the 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
Flow Graph Graph Matrix 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. 43
A connection matrix is used to find the cyclomatic complexity of the control graph.
Following are the steps to compute the cyclomatic complexity :
• Count the number of 1s in each row and write it in the end of the row
• Subtract 1 from this count for each row (Ignore the row if its count is 0)
• Add the count of each row calculated previously
• Add 1 to this total count
• The final sum in Step 4 is the cyclomatic complexity of the control flow graph
Cyclomatic Complexity
e-n+2=5-4+2=3
P+1 = 2 +1 = 3
R +1 = 2 +1 = 3
Path 1: 1, 2, 4
Path 2: 1, 3, 4
Path 3: 1, 1, 3, 4
44
Graph Matrix Connection Matrix Cyclomatic Complexity Calc
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
1 a 1 1 1 1 1-1= 0
2 2 2
3 d b 3 1 1 3 1 1 2-1 = 1
4 c f 4 1 1 4 1 1 2-1 = 1
5 g e 5 1 1 5 1 1 2-1 = 1
CC = 0=+1+1+1 + 1 = 4
1
Flow Graph a
Path 1: 1, 3, 4, 2
e 3 Path 2: 1, 3, 4, 5, 2
Path 3: 1, 3, 4, 5, 3
b
5 f Path 4: 1, 3, 2
4
d
g c
2
45
3. Control Structure Testing
Control structure testing is used to increase the
coverage area by testing various control structures
present in the program. The different types of testing
performed under control structure testing are as
follows
i. Condition Testing - a test case design method that exercises the
logical conditions contained in a program module
ii. Data Flow Testing - selects test paths of a program according to
the locations of definitions and uses of variables in the program
iii. Loop Testing - It specifically focuses on the validity of loop
construction.
46
i. Condition Testing
Condition testing is a test case design method, which ensures that the logical condition and
decision statements are free from errors.
The errors present in logical conditions can be incorrect Boolean operators, missing
parenthesis in a Boolean expression, error in relational operators, arithmetic expressions,
and so on.
The common types of logical conditions that are tested using condition testing are -
1. A relation expression, like E1 op E2 where ‘E1’ and ‘E2’ are arithmetic expressions and
‘OP’ is an operator.
2. A simple condition like any relational expression preceded by a NOT (~) operator.
For example, (~E1) where ‘E1’ is an arithmetic expression and ‘ ~ ’ denotes NOT
operator.
4. A Boolean expression consists of operands and a Boolean operator like ‘AND’, OR,
NOT.
For example, ‘A|B’ is a Boolean expression where ‘A’ and ‘B’ denote operands
and | denotes OR operator. 47
ii. Data Flow Testing
The data flow test method chooses the test path of a program
based on the locations of the definitions and uses all the
variables in the program.
48
iii. Loop Testing
Simple
loop
Nested
Loops
Concatenated
Loops Unstructured
Loops
49
Simple Loop – The following set of test can be applied to simple loops, where the
maximum allowable number through the loop is n.
• Skip the entire loop.
• Traverse the loop only once.
• Traverse the loop two times.
• Make p passes through the loop where p<n.
• Traverse the loop n-1, n, n+1 times.
Concatenated Loops – If loops are not dependent on each other, contact loops can
be tested using the approach used in simple loops. if the loops are
interdependent, the steps are followed in nested loops
Nested Loops – Loops within loops are called as nested loops. when testing nested
loops, the number of test increases as level nesting increases.
The following steps for testing nested loops are as follows-
• Start with inner loop. set all other loops to minimum values.
• Conduct simple loop testing on inner loop.
• Work outwards.
• Continue until all loops tested.
Unstructured loops – This type of loops should be redesigned, whenever possible,
to reflect the use of unstructured the structured programming
constructs.
50
51
52
Black-Box Testing
requirements
output
input events
53
Black Box Testing
• Black-box testing, also called behavioral testing, focuses on the functional
requirements of the software.
• That is, black-box testing enables the software engineer to derive sets of input
conditions that will fully exercise all functional requirements for a program.
54
Black Box Testing
➢ Black-box testing attempts to find errors in the following
categories:
1. incorrect or missing functions,
2. interface errors,
3. errors in data structures or external data base access,
4. behavior or performance errors, and
5. initialization and termination errors.
55
1.
56
57
58
2. Equivalence partitioning
• Equivalence partitioning is a black-box testing method
that divides the input domain of a program into
classes of data from which test cases can be derived.
60
3. Boundary Value Analysis
• A greater number of errors occur at the boundaries of
the input domain rather than in the "center“
61
Guidelines for Boundary Value Analysis
3. Apply guidelines 1 and 2 to output conditions; produce output that reflects the
minimum and the maximum values expected; also test the values just below and
just above
62
Boundary Value Analysis
Consider a program with two input variables x and y. These input variables have specified boundaries as:
a≤x≤b
c≤y≤d
Input domain
d
y
c
a b
x
Input domain for program having two input variables
63
The boundary value analysis test cases for our program with two inputs
variables (x and y) that may have any value from 100 to 300 are:
(200,100), (200,101), (200,200), (200,299), (200,300), (100,200),
(101,200), (299,200) and (300,200). This input domain is shown. Each
dot represent a test case and inner rectangle is the domain of
legitimate inputs. Thus, for a program of n variables, boundary value
analysis yield 4n + 1 test cases.
Input domain
400
300
y 200
100
66