The University of Lahore
A “W4” Category University
07/10/2020 1
Lecture 25
CHAPTER 4
The University of Lahore
A “W4” Category University
The University of Lahore
A “W4” Category University
07/10/2020 3
Specification-Based OR Black-Box OR I/O Testing Techniques
It view the software as a black box with inputs and outputs, but they have no knowledge of how the system or component is structured inside the box.
The University of Lahore
A “W4” Category University
Equivalence Partitioning (EP)
is to divide the input data of a software into partition of
data from which test cases can be derived.
The University of Lahore
A “W4” Category University
07/10/2020 5
Equivalence Partitioning:
1. In this method the input domain data is divided into different equivalence data classes.
2. This method is typically used to reduce the total number of
test cases.
The University of Lahore
A “W4” Category University
EXAMPLE 1
If you are testing for an input box accepting numbers
from 1 to 1000 then there is no use in writing thousand
test cases for all 1000 valid input numbers plus other
test cases for invalid data.
The University of Lahore
A “W4” Category University
07/10/2020 7
1. One input data class with all valid inputs. Pick a single value from range 1 to 1000 as a valid test case. If you select other values between 1 and 1000 then result is going to be same. So one test case for valid input data should be sufficient.
2. Input data class with all values below lower limit. I.e. any value below 1, as a invalid input data test case.
The University of Lahore
A “W4” Category University
EXAMPLE 2
The valid range for the month is 1 to 12, representing January to December. This valid range is called a partition. In this example there are two further partitions of invalid ranges. The first invalid partition would be <= 0 and the second invalid partition would be >= 13.
The University of Lahore
A “W4” Category University
07/10/2020 9
1. An input has certain ranges which are valid and other ranges which are invalid.
2. Only one test case of each partition is needed to evaluate the behaviour of the program
3. Use more or even all test cases of a partition will not find new faults in the program.
4. If one condition in the partition work we assume all of the conditions in that partition will work.
5. The number of test cases can be reduced considerably.
The University of Lahore
A “W4” Category University
Example 3
Consider a form field which ask for the age of a person. let the age should be >=18 and <=50.
SOLUTION
==>> values less than 18(invalid class) ==>> values between 18-50 (valid class) ==>> value greater than 50 (invalid class)
The University of Lahore
A “W4” Category University
07/10/2020 11
CLASS WORK 1
The following input conditions will be tested:
1. For the first three digits of all social security
numbers, the minimum number is 111 and the
maximum number is 222.
The University of Lahore
A “W4” Category University
SOLUTION
The first three digits of the social security number are:
1. >= 111 and < =222 (valid input),
The University of Lahore
A “W4” Category University
07/10/2020 13
The fourth and fifth digits of the social insurance (security) number are:
5. >= 11 and <= 99, (valid input)
6. < 11 (invalid input, below the range)
The University of Lahore
A “W4” Category University
CLASSWORK 2
What will be the equivalence partitions if:
1. A balance in the range $0 up to $100
2. A balance over $100 and less than $1000 3. A balance of $1000 and over.
The University of Lahore
A “W4” Category University
07/10/2020 15
Invalid
partition (3% interest)Valid (5% interest)Valid (7% interest)Valid
-$0.01 $0.00 $100.00 $100.01 $999.99 $>=1000.00
The University of Lahore
A “W4” Category University
Class Work 3
How to apply Equivalence Partitions if:
The University of Lahore
A “W4” Category University
07/10/2020 17
SOLUTION
Divide the students under the same intervals for same
group according to there age
The University of Lahore
A “W4” Category University
Purpose of Equivalence Partitioning
The University of Lahore
A “W4” Category University
07/10/2020 19
Boundary Value (BV)
“An input value or output value which is on the edge of
equivalence partition e.g. the minimum and maximum
value of a range.”
Boundary Value Analysis (BVA)
The University of Lahore
A “W4” Category University
1. It’s widely recognized that input values at the extreme
ends of input domain cause more errors in system.
2. More application
errors occur at the boundaries of
input domain. ‘Boundary value analysis’ testing
technique is used to identify errors at boundaries
rather than finding those exist in center of input
domain.
The University of Lahore
A “W4” Category University
07/10/2020 21
Test cases for input box accepting numbers between 1
and 1000 using Boundary value analysis:
1. Test cases with test data exactly as the input
boundaries of input domain i.e. values 1 and 1000 in
our case.
2. Test data with values just below the extreme edges of
input domains i.e. values 0 and 999.
The University of Lahore
A “W4” Category University
Boundary Value Analysis PROCEDURE
There is an interval from 0 to 10 then in the BVA attempt 6 step procedure:
1) Check for the (min-1) 0-1=-1 2) Check for the (min) 0
The University of Lahore
A “W4” Category University
07/10/2020 23
Boundary Value Analysis (Range Checking)
“An input value or output value which is on the edge of
equivalence partition e.g. the minimum and maximum
value of a range.”
Example1
Consider a printer that has an input option of the
number of copies to be made, from 1 to 99
invalid valid invalid
The University of Lahore
A “W4” Category University
invalid valid invalid
0 1 99 100
In boundary value analysis , we will take the min and max (boundary) values from the valid partition (1 and 99 in this case), together with first and last value in each of invalid partitions (0 and 100 in this case)
The University of Lahore
A “W4” Category University
07/10/2020 25
Invalid
partition (3% interest)Valid (5% interest)Valid (7% interest)Valid
-$0.01 $0.00 $100.00 $100.01 $999.99 $1000.00
Class Work 1
The University of Lahore
A “W4” Category University
How to calculate the max value for 7% interest?
Invalid
partition (3% interest)Valid (5% interest)Valid (7% interest)Valid
-$0.01 $0.00 $100.00 $100.01 $999.99 $1000.00
1- Go back to the specification to see if a max has been stated somewhere for the balance amount.
The University of Lahore
A “W4” Category University
07/10/2020 27
CLASSWORK 2
Equivalence partition and boundary value analysis
Telephone system for a company with 200 telephones has 3 digit extension numbers from 100 to 699.
We can identify the following partitions and boundaries
-Digits (0 to 9): valid partition(s) ___________ invalid partition(s) ______ -Number of digits: invalid boundary values ______ and ________
-Range of extension numbers :
valid _____ and ______ ,invalid boundary value _____ and ___
The University of Lahore
A “W4” Category University
07/10/2020 29
The University of Lahore
A “W4” Category University
EXAMPLE
Consider a component, generate_grading, with the following specification:
The component is passed an exam mark (out of 75) and a coursework (c/w) mark (out of 25), from which it generates a grade for the course in the range 'A' to 'D'. The grade is calculated from the overall mark which is calculated as the sum of the exam and c/w marks, as follows:
greater than or equal to 70 - 'A'
The University of Lahore
A “W4” Category University
07/10/2020 31
The partitions for the two inputs are initially identified.
The
valid partitions
can be described by:
0 <= exam mark <= 75
0 <= coursework mark <= 25
The most obvious
invalid partitions
based on the inputs
can be described by:
exam mark > 75
exam mark < 0
The University of Lahore
A “W4” Category University
The University of Lahore
A “W4” Category University
07/10/2020 33
The University of Lahore
A “W4” Category University
CLASS EXERCISE
The University of Lahore
A “W4” Category University
07/10/2020 35
• Why use decision table • Decision table definition • Applications
• Steps to create a decision
table
The University of Lahore
A “W4” Category University
Why Use Decision Tables?
Equivalence partitioning and boundary value analysis applied to specific inputs.
The University of Lahore
A “W4” Category University
07/10/2020 37
HOW?
1. One of the fields on a form contains a text box which accepts numeric values in the range of 18 to 25. Identify the invalid Equivalence class.
2. In an Examination a candidate has to score minimum of 24 marks in order to clear the exam. The maximum that he can score is 40 marks. Identify the Valid Equivalence values if the student clears the exam.
The University of Lahore
A “W4” Category University
Why Use Decision Tables?
1. Equivalence partitioning and boundary value analysis applied to specific inputs.
The University of Lahore
A “W4” Category University
07/10/2020 39
Definition
“A table showing combinations of inputs (causes/conditions) with
their associated outputs (effects/expected
results/actions/outcomes ), which can be used to design test cases.”
Causes Values 1 2 3 4 5 6 7 8
Cause 1 Y, N Y Y Y Y N N N N
Cause 2 Y, N Y Y N N Y Y N N
Cause 3 Y, N Y N Y N Y N Y N
Effects
Effect 1 X X X
Effect 2 X X X
The University of Lahore
A “W4” Category University
Decision Table Testing
The University of Lahore
A “W4” Category University
07/10/2020 41
1. List all causes in the decision table
2. Calculate the number of possible combinations
3. Fill columns with all possible combinations
4. Check covered combinations 5. Add effects to the table
The University of Lahore
A “W4” Category University
Step 1: List all causes
Causes Values 1 2 3 4 5 6 7 8 Cause 1 Y, N Y Y Y Y N N N N Cause 2 Y, N Y Y N N Y Y N N Cause 3 Y, N Y N Y N Y N Y N
Effects
Effect 1 X X X
Effect 2 X X X
The University of Lahore
A “W4” Category University
07/10/2020 43
Step 2: Calculate Combinations
•
If all causes are simply Y/N
OR T/F values:
Causes Values 1 2 3 4 5 6 7 8
Cause 1 Y, N Y Y Y Y N N N N
Cause 2 Y, N Y Y N N Y Y N N
Cause 3 Y, N Y N Y N Y N Y N
Effects
Effect 1 X X X
Effect 2 X X X
Combinations
The University of Lahore
A “W4” Category University
Step 3: Fill Columns
Conditions 1 2 3 4 5 6 7 8
The University of Lahore
A “W4” Category University
07/10/2020 45
Step 4: Check Covered Combinations
• Checksum
• For each column calculate the
combinations it represents
Causes Values 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Customer Type A,B,C,O A A A A B B B B C C C C O O O O
2 or more lines Y, N Y Y N N Y Y N N Y Y N N Y Y N N
Credit rating = X Y, N Y N Y N Y N Y N Y N Y N Y N Y N
Effects
Normal Letter X X X X X X X X ? ? ? ?
Special Letter X X X X ? ? ? ?
Add. Paragraph ? X X ? X X ? X X ? ? ? ?
No Letter ? ? ? ?
Checksum 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 16
The University of Lahore
A “W4” Category University
Conditions 1 2 3 4 1. Deductible met? Y Y N N 2. Type of visit D H D H Actions
1. Reimburse 50% X
Step 5: Add effects to table
• Read column by column
The University of Lahore
A “W4” Category University
07/10/2020 47
Example Decision Table
Loan application, where you can enter the amount of monthly repayment OR the number of years to take to pay it back.
The University of Lahore
A “W4” Category University
Step 2: Calculate the Combinations
The University of Lahore
A “W4” Category University
07/10/2020 49
The University of Lahore
A “W4” Category University
Step 5: Add Effects to Columns
The University of Lahore
A “W4” Category University
07/10/2020 51
The University of Lahore
A “W4” Category University
Change Outcome
The University of Lahore
A “W4” Category University
The University of Lahore
A “W4” Category University
The University of Lahore
A “W4” Category University
07/10/2020 55