You are on page 1of 53

Software Testing

Software Testing

 Process of executing a program with the intent of finding


errors

 Act of designing & Executing test

Prakash.J PSG College of Technology


Testing vs Debugging

 Testing is to show that the program has bugs

 Debugging is to locate & Correct the errors or


misconceptions that cause the program fail.

Prakash.J PSG College of Technology


Test Characteristics
1) A good test has a high probability of finding an error.

2) A good test is not redundant.

3) A good test is the “best of breed”.

4) A good test should be neither too simple nor too complex.

Prakash.J PSG College of Technology


VERIFICATION

 Are we building the system right ?

 Ensures that the system developed is error free


without defects (i.e., does not mean that it
need to satisfy the requirement specification)

Prakash.J PSG College of Technology


VALIDATION

 Are we building the right system ?

 Ensure the system is delivered as per the


requirement of the customer
(i.e, meeting the requirement specification)

Prakash.J PSG College of Technology


Testing Techniques
Black Box Testing
 Black box testing involves looking at the specifications and
does not require examining the code of a program.

 Black box testing is done from the customer's viewpoint.

White Box Testing


 White box testing is a way of testing the external functionality
of the code by examining and testing the program code that
realizes the external functionality.

 This is also known as clear box, or glass box or open box


testing.

Prakash.J PSG College of Technology


BLACK BOX TESTING TECHNIQUES

 Requirements based  State based testing


testing  Compatibility testing
 Positive and negative  User documentation
testing testing
 Boundary value  Domain testing
analysis
 Decision tables
 Equivalence partitioning

Prakash.J PSG College of Technology


BOUNDARY VALUE ANALYSIS
 A method useful for arriving at tests that are
effective in catching defects that happen at
boundaries

 BVA believes and extends the concept that the


density of defect is more towards the boundaries.

Prakash.J PSG College of Technology


BOUNDARY VALUE ANALYSIS

 Consider a billing system that offers discounts to


customers.
 The concept of volume discounts when we buy
goods —buy one packet of chips for $1.59 but
three for $4.
 It becomes economical for the buyer to buy in
bulk.
 From the seller's point of view also, it is
economical to sell in bulk.

Prakash.J PSG College of Technology


BOUNDARY VALUE ANALYSIS
Number of units bought Price per unit

First ten units (that is, from 1 to 10 units) $5.00

Next ten units (that is, from units 11 to 20 units) $4.75

Next ten units (that is, from units 21 to 30 units) $4.50

More than 30 units $4.00

From the above table, If we buy 5 units, we pay 5*5 = $25. If we buy 11 units,
we pay 5*10 = $50 for the first ten units and $4.75 for the eleventh item.
Similarly, if we buy 15 units, we will pay 10*5 + 5*4.75 = $73.75.

Prakash.J PSG College of Technology


BOUNDARY VALUE ANALYSIS
 Generally it has been found that most defects in situations such as this
happen around the boundaries
 for example, when buying 9, 10, 11, 19, 20, 21, 29, 30, 31, and similar
number of items.
 The reasons for this phenomenon is not entirely clear, some possible
reasons are as follows.
 Programmers’ tentativeness in using the right comparison operator, for
example, whether to use the < = operator or < operator when trying to
make comparisons.
 Confusion caused by the availability of multiple ways to implement
loops and condition checking.
 The requirements themselves may not be clearly understood.

Prakash.J PSG College of Technology


EQUIVALENCE PARTITIONING

 IT involves identifying a small set of representative input values


that produce as many different output conditions as possible.

 This reduces the number of permutations and combinations of


input, output values used for testing, thereby increasing the
coverage and reducing the effort involved in testing.

Prakash.J PSG College of Technology


EQUIVALENCE PARTITIONING

1 – 100

1 – 20 21 – 40 41 – 60 61 – 80 81 - 100

Prakash.J PSG College of Technology


EQUIVALENCE PARTITIONING
TECHNIQUE

 Testing by this technique involves

1. identifying all partitions for the complete set of input, output


values for a product.
2. picking up one member value from each partition for testing to
maximize complete coverage.

Prakash.J PSG College of Technology


EQUIVALENCE PARTITIONING
TECHNIQUE
 consider the example of an insurance company that has the following premium
rates based on the age group.

Age group Additional premium


Under 35 $1.65
35-59 $2.87
60+ $6.00

 A life insurance company has base premium of $0.50 for all ages.
 Based on the age group, an additional monthly premium has to be paid that is as
listed in the table below.
 For example, a person aged 34, has to pay a premium=base premium +
additional premium=$0.50 + $1.65=$2.15.

Prakash.J PSG College of Technology


EQUIVALENCE PARTITIONING
TECHNIQUE

 Based on the equivalence partitioning technique,


the equivalence partitions that are based on age
are given below:

 Below 35 years of age (valid input)


 Between 35 and 59 years of age (valid input)
 Above 60 years of age (valid input)
 Negative age (invalid input)
 Age as 0 (invalid input)
 Age as any three-digit number (valid input)

Prakash.J PSG College of Technology


White Box Testing

 Basis Path Testing

 Control Structure Testing


 Conditional Testing
 Data Flow Testing
 Loop Testing

Prakash.J PSG College of Technology


BASIS PATH TESTING

DERIVING TEST CASES

Prakash.J PSG College of Technology


FlowGraph

Prakash.J PSG College of Technology


Solution

Prakash.J PSG College of Technology


Independent program paths

 Path 1: 1-11

 Path 2: 1-2-3-4-5-10-1-11

 Path 3: 1-2-3-6-8-9-1-11

 Path 4: 1-2-3-6-7-9-1-11

 Path 5: 1-2-3-4-5-10-1-2-3-6-8-9-1-11

Prakash.J PSG College of Technology


Cyclomatic complexity
1. The no. of regions corresponds to the cyclomatic complexity.

2. Cyclomatic complexity, V(G), for a flow graph, G, is defined as


V(G) = E - N + 2
where E is the number of flow graph edges, N is the number of
flow graph nodes.

3. Cyclomatic complexity, V(G), for a flow graph, G, is also defined as


V(G) = P + 1
where P is the number of predicate nodes edges.

Prakash.J PSG College of Technology


 Regions:
V(G) = 4 regions

 Edge and Node:


V(G) = Edge – Node +2
V(G) = 11 – 9 + 2
V(G) = 4

 Predicate Nodes:
V(G) = Predicate Nodes + 1
V(G) = 3 + 1
V(G) = 4

Prakash.J PSG College of Technology


Graph Matrices:
 A graph matrix is a square matrix whose size (i.e., number of
rows and columns) is equal to the number of nodes on the
flow graph.

 Each row and column corresponds to an identified node, and


matrix entries correspond to connections (an edge) between
nodes.

Prakash.J PSG College of Technology


Prakash.J PSG College of Technology
Each row with two or more entries represents a
predicate node.
Prakash.J PSG College of Technology
EXAMPLE

Prakash.J PSG College of Technology


PROCEDURE

 This procedure computes the average of


100 or fewer numbers that lie between
bounding values

 It also computes the sum and the total


number valid.

Prakash.J PSG College of Technology


Prakash.J PSG College of Technology
Prakash.J PSG College of Technology
STEP - 1

Using the design or code as a


foundation, Draw a corresponding flow graph

Prakash.J PSG College of Technology


Prakash.J PSG College of Technology
STEP - 2

Determine the cyclomatic


complexity of the resultant flow graph

Prakash.J PSG College of Technology


REGIONS

Prakash.J PSG College of Technology


 Regions:
V(G) = 6 regions

 Edge and Node:


V(G) = Edge – Node +2
V(G) = 17 – 13 + 2
V(G) = 6

 Predicate Nodes:
V(G) = Predicate Nodes + 1
V(G) = 5 + 1
V(G) = 6

Prakash.J PSG College of Technology


STEP - 3

Determine the basis set of linearly


independent paths.

Prakash.J PSG College of Technology


Prakash.J PSG College of Technology
 PATH – 1 :

1-2-10-11-13
 PATH – 2 :

1-2-10-12-13
 PATH – 3 :

1-2-3-10-11-13
 PATH – 4 :

1-2-3-4-5-8-9-2-….
 PATH – 5 :

1-2-3-4-5-6-8-9-2-….
 PATH – 6 :

Prakash.J
1-2-3-4-5-6-7-8-9-2-….
PSG College of Technology
STEP - 4

Prepare a test cases that will force


execution of each path in the basis

Prakash.J PSG College of Technology


 PATH – 1 :

1-2-10-11-13
 PATH – 2 :

1-2-10-12-13
 PATH – 3 :

1-2-3-10-11-13
 PATH – 4 :

1-2-3-4-5-8-9-2-….
 PATH – 5 :

1-2-3-4-5-6-8-9-2-….
 PATH – 6 :

Prakash.J
1-2-3-4-5-6-7-8-9-2-….
PSG College of Technology
Prakash.J PSG College of Technology
INPUT EXPECTED OUTPUT PASS / FAIL

Test Case – 1
Path – 1
Sum = 45 , Total valid = 10 Average = 4.5 Pass
Value [1] = - 999

Test Case – 2
Path – 2
Sum = 100 , Total valid = 0 Average = - 999 Pass
Value [1] = - 999

Test Case – 3
Path – 3
Min = 1, Max = 11, Average = 0.9 Pass
Total.input = 101
Value[1, 2, 3, …., 101]
Sum = 100
Prakash.J PSG College of Technology
INPUT EXPECTED OUTPUT PASS / FAIL

Test Case – 4
Path – 4
Min = 1, Max = 10, Average = - 999 Pass
Value[0, 2, 3, …., 10]

Min = 1, Max = 10, Average = 4.5 Pass


Value[1, 2, 3, …., 10,0]
Test Case – 5
Path – 5
Min = 1, Max = 11, Average = 4.5 Pass
Value[1, 2, 3, …., 11]

Min = 1, Max = 11, Average = - 999 Pass


Value[11, 2, 3, …., 10]

Prakash.J PSG College of Technology


INPUT EXPECTED OUTPUT PASS / FAIL

Test Case – 6
Path – 6
Min = 1, Max = 11, Average = 4.5 Pass
Value[1, 2, 3, …., 10]

Prakash.J PSG College of Technology


Control Structure Testing
Conditional Testing

Prakash.J PSG College of Technology


Conditional Testing

Prakash.J PSG College of Technology


Loop Testing

Prakash.J PSG College of Technology


Loop Testing

Prakash.J PSG College of Technology


Loop Testing

Prakash.J PSG College of Technology


Loop Testing

Prakash.J PSG College of Technology


Loop Testing

Prakash.J PSG College of Technology


Loop Testing

Prakash.J PSG College of Technology

You might also like