Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 53

Black Box Testing

Equivalence Class
Partitioning
Typical Saudi breakfast – how would
you test it yaaa habibeeeee????
 Anequivalence class consistsof a set of
data that is treated the same by the
module or that should produce the same
result.
Equivalence Partitions Must Be Disjoint
 No two of the subsets can have one or more
members in common

Repeating members

8
To define equivalence classes follow the guideline

1. If an input condition specifies a range, one


valid and two invalid equivalence classes
are defined.
2. If an input condition requires a specific
value, one valid and two invalid
equivalence classes are defined.
3. If an input condition is Boolean, one valid
and one invalid class are defined.
Test cases for input box accepting numbers
between 1 and 1000 using Equivalence Partitioning

 One input data class with all valid inputs. Pick


a single value from range 1 to 1000
 Input data class with all values below lower

limit. I.e. any value below 1, as a invalid input


data test case
 Input data with any value greater than 1000

to represent third invalid input class.


Test Case of Grocery Store
Application

Consider a software module that is intended to accept the


name of a grocery item and a list of the different sizes the item
comes in, specified in ounces. The specifications state that the
item name is to be alphabetic characters 2 to 15 characters in
length. Each size may be a value in the range of 1 to 48, whole
numbers only. The sizes are to be entered in ascending order
(smaller sizes first). A maximum of five sizes may be entered
for each item. The item name is to be entered first, followed by
a comma, then followed by a list of sizes. A comma will be used
to separate each size. Spaces (blanks) are to be ignored
anywhere in the input.
 Derived Equivalence Classes
1. Item name is alphabetic (valid)
2. Item name is not alphabetic (invalid)
3. Item name is less than 2 characters in length (invalid)
4. Item name is 2 to 15 characters in length (valid)
5. Item name is greater than 15 characters in length (invalid)
6. Size value is less than 1 (invalid)
7. Size value is in the range 1 to 48 (valid)
8. Size value is greater than 48 (invalid)
9. Size value is a whole number (valid)
10.Size value is a decimal (invalid)
11.Size value is numeric (valid)
12.Size value includes nonnumeric characters (invalid)
13.Size values entered in ascending order (valid)
14.Size values entered in nonascending order (invalid)
15.No size values entered (invalid)
16.One to five size values entered (valid)
17.More than five sizes entered (invalid)
18.Item name is first (valid)
19.Item name is not first (invalid)
20.A single comma separates each entry in list (valid)
21.A comma does not separate two or more entries in the list
(invalid)
22.The entry contains no blanks (???)
23.The entry contains blanks (????)
Expected
Test Data Classes Covered
Outcome
1,4,7,9,11,13,16,18,20,
xy,1 T
22
AbcDefghijklmno,1,2, 1,4,7,9,11,13,16,18,20,
T
3  ,4,48 23
a2x,1 F 2
A,1 F 3
Abcdefghijklmnop F 5
Xy,0 F 6
XY,49 F 8
Xy,2.5 F 10
xy,2,1,3,4,5 F 14
Xy F 15
XY,1,2,3,4,5,6 F 17
1,Xy,2,3,4,5 F 19
Class Activity – Test cases by using ECP
techniques
 A savings account in a bank has a different rate of interest
depending on the balance in the account. In order to test the
software that calculates the interest due, identify the ranges of
balance values that earn the different rates of interest. For example,
3% rate of interest is given if the balance in the account is in the
range of $0 to $100, 5% rate of interest is given if the balance in the
account is in the range of $100 to $1000, and 7% rate of interest is
given if the balance in the account is $1000 and above , ECP
Id Input Expected output Actual output
1 -5 NA
2 50 3%
3 150 5%
4 1050 7%
5 -1 NA
6 0 3%
7 1 3%
8 99 3%
9 100 --
10 101 5%
11 999 5%
12 1000 --
13 1001 7%
Test Cases for previous activity

Id Input Expected output Actual output status


1 -1 Invalid
2 50 3%
3 150 5%
4 1100 7%

SO THE CONCLUSION IS : IN CASE OF REPETITION, YOU HAVE TO


DELETE THE DUPLICATIONS OF TEST CASES.
Equivalence Partitioning (EP)
 Example 1:
 interest due = balance * interest rate
 Test cases are ready

Test Case Input Expected output


ID
1 -10 Error message
2 50 1.5
3 260 13
4 1348 94.36
Let’s create a form with these
specs
Setting one invalid at a time

invalid Valid Valid Valid


invalid Valid Valid Valid
Valid inValid Valid Valid
Valid inValid Valid Valid
Valid valid Invalid Valid
Valid Valid Valid Invalid
Exercises
1. A switch is switched on once the
temperature falls below 18 degrees and then
it is turned off when the temperature is more
than 21. Identify the equivalence values for
testing the switch.

24
Exercises
1. 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 Valid equivalence values if
the student clears the exam.

25
Exercises
1. One of the fields on a form contains a text
box which accepts numeric values in the
range of 18 to 25. Define the equivalence
classes.

26
Exercises

A program validates a numeric field as follows:


Values less than 10 are rejected, values
between 10 and 21 are accepted, values greater
than or equal to 22 are rejected. Which of the
input values cover all of the equivalence
partitions?

27
Exercises

1. In a system designed to work out the tax to


be paid: An employee has £4000 of salary
tax free. The next £1500 is taxed at 10%.
The next £28000 is taxed at 22%. Any
further amount is taxed at 40%. Define the
equivalence classes.

28
Boundary Value Analysis
Chapter 4
Book 2
Rules for hiring
 0–16 Don't hire
 16–18Can hire on a part-time basis only
 18–55Can hire as a full-time employee
 55–99Don't hire

 Boundary value testing focuses on the


boundaries simply because that is where so
many defects hide.
Incorrect code
If (applicantAge >= 0 && applicantAge <=16)
hireStatus="NO";
If (applicantAge >= 16 && applicantAge <=18)
hireStatus="PART";
If (applicantAge >= 18 && applicantAge <=55)
hireStatus="FULL";
If (applicantAge >= 55 && applicantAge <=99)
hireStatus="NO";
organization meant :
 0–15Don't hire
 16–17Can hire on a part-time basis only
 18–54Can hire as full-time employees
 55–99Don't hire
What can be the possible reasons
behind this code ??
Corrected code
If (applicantAge >= 0 && applicantAge <=15)
hireStatus="NO";
If (applicantAge >= 16 && applicantAge <=17)
hireStatus="PART";
If (applicantAge >= 18 && applicantAge <=54)
hireStatus="FULL";
If (applicantAge >= 55 && applicantAge <=99)
hireStatus="NO";
Technique
 First, identify the equivalence classes.

 Second, identify the boundaries of each


equivalence class.

 Third, create test cases for each boundary


value by choosing one point on the boundary,
one point justbelow the boundary, and one
point just above the boundary.
Boundary values
 0–15Don't hire
 16–17Can hire on a part-time basis only
 18–54Can hire as full-time employees
 55–99Don't hire

 Boundary values ??
What about the values that are not
specified in requirements? ?
 -3
 101
 Abc ??
You could, of course, create additional test
cases farther from the boundaries (within
equivalence classes) if you have the resources.

 These additional test cases may make you


feel warm and fuzzy, but they rarely discover
additional defects.
Applicable to value & structure
Example: Printer

 Number of copies : ______


 Valid values 1-99

 Equivalence partitioning Test Cases


 Boundary value test cases
Example: Number of Tickets

 Equivalence partitioning Test Cases


 Boundary value test cases
Equivalence and Boundary Value
 Suppose a password field accepts minimum 6
characters and maximum 10 characters

 Banking system Example.

 Input Box should accept the Number between


1 and 10 Test Scenario
 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.
a)    17
b)    19
c)    24
d)    21
One of the fields on a form contains a text box
which accepts alpha numeric values. Identify
the Valid Equivalence class value
a)    BOOK
b)    Book
c)    Boo01k
d)    Book
 A program validates a numeric field as follows:
values less than 10 are rejected, values between
10 and 21 are accepted, values greater than or
equal to 22 are rejected. Which of the following
covers the MOST boundary values?
a. 9,10,11,22
b. 9,10,21,22
c. 10,11,21,22
d. 10,11,20,21
e. All are equal
Solve …
 Assume that a software has a data-entry field
for a 9-digit ZIP code, such as the one shown
in the Figure. What equivalence partitions
would you create for this text box?

 What boundary value test cases would you


create?
Solve for boundary analysis
 A savings account in a bank has a different rate of
interest depending on the balance in the account.
In order to test the software that calculates the
interest due, identify the ranges of balance values
that earn the different rates of interest. For
example, 3% rate of interest is given if the balance
in the account is in the range of $0 to $100, 5%
rate of interest is given if the balance in the
account is in the range of $100 to $1000, and 7%
rate of interest is given if the balance in the
account is $1000 and above,
 Summary:
 Boundary Analysis testing is used when practically it is
impossible to test large pool of test cases individually
 Two techniques - Equivalence Partitioning & Boundary
Value Analysis testing techniques is used
 In Equivalence Partitioning, first you divide a set of test
condition into a partition that can be considered.
 In Boundary Value Analysis you then test boundaries
between equivalence partitions
 Appropriate for calculation-intensive applications with
variables that represent physical quantities

You might also like