0% found this document useful (0 votes)
14 views43 pages

Test Case Design Using Black Box Techniques

Uploaded by

hashemgtr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views43 pages

Test Case Design Using Black Box Techniques

Uploaded by

hashemgtr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 43

Chapter 2: Test Case

Design Using Black


Box Techniques
Unit testing
 It focuses on the smallest possible unit of the software application such
as Function, Method, or a Class.
 Defects can be caught as early as possible during development.
 We are able to test parts of a project without waiting for the other parts
to be available.
 We will be able to test internal conditions that are not easily reached by
external inputs in the larger integrated systems.
Types of unit testing
1. White Box testing (Internal Structure testing): Access to the source
code

2. Grey Box testing (DB, Distributed Apps, etc..)

3. Black Box testing (Functional testing): The program is a black box --


you can’t see into it.
Black-Box Testing
 Black-box testing is testing from a functional or behavioural
perspective to ensure a program meets its requirements specifications.
 Testing usually conducted without knowing the internal structure of the
code (System implementation)- system treated as a “black box”. Only
know system input(s)/outputs.
Objectives of black-box testing
1. Identify incorrect or missing functionalities (functional testing).
2. Identify performance errors (non functional testing) .
3. Identify errors in links with other programs such as databases.
4. Identify errors resulting from performing a program maintenance or
even doing update on it (regression testing)
5. Identify initialization and/or termination errors.
Black Box Testing Techniques
 Equivalence partitioning technique (EQP)
 Boundary value analysis (BVA)
 Decision Table (DT)
 Cause-Effect Graph (Graph based technique).
 Use case analysis technique.
 State-transition analysis technique.
Equivalence
partitioning &
Boundary Value
Analysis
Equivalence partitioning
 It divides the input domain (the set of values that can be used as input)
into mutually disjoint subsets called ‘equivalence classes’

 Each member in a subset has the same characteristic as that of the other
elements in the same subset.
Equivalence classes for variables: range
Eq. Classes Example
Constraints Classes
One class with speed {50}, {75},
values inside the [60..90] {92}
range and two with
values outside the
range.

area: float {{-1.0},


area0.0 {15.52}}
age: int {{-1}, {56},
{132}}
Letter : char {{J}, {3}}
Equivalence classes for variables: String

Eq. Classes Example


Constraints Classes
At least one firstname: {{}, {Sue},
containing all legal string {Loooong
strings and one all Name}}
illegal strings based
on any constraints.
Equivalence classes for variables: enumeration

Eq. Classes Example


Constraints Classes
Each value in a separate autocolor:{red, {{red,} {blue},
class blue, green} {green}}
up: Boolean {{true}, {false}}
Equivalence classes for variables: arrays

Eq. Classes Example


Constraints Classes
One class containing all int [ ] aName: {[ ]}, {[-10, 20]},
legal arrays, one new int[3]; {[-9, 0, 12, 15]}
containing the empty
array, and one
containing a larger than
expected array.
EQP Example 1 (Interest Rate %)
EQP Example 2 (Factorial N!)
A factorial program accepts only one integer value (n) and returns its
factorial. If the input is negative the program returns zero, if the input is
either one or zero the program returns 1, otherwise it return N!.
Question: Find all test cases using EQP method.
EQP Example 3 (Phone Number)
A function that accepts an input as a local phone number (3 digit
prefix followed by a 4-digit number), and produce summation of
digits.
Constraints:
▫ the 3-digit prefix should be  200
▫ the 4-digit number should not be 0000
EQP Example 4
Consider a system specification which states that a program will accept
between 4 and 10 input values (inclusive), where the input values must be
5 digit integers greater than or equal to 10,000

 What are the equivalence partitions?


EQP Example 5 (Binary Search)
Consider a binary search program, the program takes an array of integers
(say elements) and integer variable called key. The program assumes that
the array is sorted in ascending order and has elements. The program
searches for the given key, if the key is found the program returns true
otherwise returns false.
 What are the equivalence partitions?
EQP Example 6 (ATM Withdraw
Function)
A program is written to simulate ATM machine. One of the important
functions of ATM system is the withdraw function. The withdraw function
accepts a specific amount as integer value. The amount must be positive
and within customer balance. Furthermore, the amount should be within
daily limit of withdrawal and must be multiplication of 10.
 What are the equivalence partitions?
EQP Question
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.
 What are the equivalence partitions?
Boundary value analysis (BVA)
 Boundary value analysis is a test selection technique that targets faults in applications
at the boundaries of equivalence classes.

 Experience indicates that programmers make mistakes in processing values at and near
the boundaries of equivalence classes.
 The basic idea in boundary value testing is to select input variable values at their: 1)
minimum-1, 2) minimum, 3) minimum+1, 4) maximum-1, 5) maximum, and 6)
maximum+1.
Example 1 on EQP and BVA
 Let'sconsider the behavior of Order Pizza Text Box Below
 Pizza values 1 to 10 is considered valid. A success message is shown,
While value 11 to 99 are considered invalid for order and an error
message will appear, "Only 10 Pizza can be ordered"
Example 1… cont
 Here is the test condition
 Any Number greater than 10 entered in the Order Pizza field(let say 11) is
considered invalid.
 Any Number less than 1 that is 0 or below, then it is considered invalid.
 Numbers 1 to 10 are considered valid
 Any 3 Digit Number say -100 is invalid.
Example 1… cont
 inBoundary Value Analysis, you test boundaries between equivalence
partitions
Example 2
 Consider an application that requires two integer inputs x and y. Each of
these inputs is expected to lie in the following ranges: 3 x7 and
5y9.

 For
unidimensional partitioning we apply the partitioning guidelines to
x and y individually. This leads to the following six equivalence classes.
Example 2 (contd.)

E1: x<3 E2: 3x7 E3: x>7 y ignored.

E4: y<5 E5: 5y9 E6: y>9 x ignored.

For multidimensional partitioning we consider the input domain to be the


set product X x Y. This leads to 9 equivalence classes.
Example 2 (contd.)

E1: x<3, y<5 E2: x<3, 5y9 E3: x<3, y>9

E4: 3x7, y<5 E5: 3x7, 5y9 E6: 3x7, y>9

E7: >7, y<5 E8: x>7, 5y9 E9: x>7, y>9


Example 2 (contd.)
E1: x<3, y<5
E3: x<3, y>9
E2: x<3, 5y9
E4: 3x7, y<5
E5: 3x7, 5y9
E6: 3x7, y>9
E7: >7, y<5
E8: x>7, 5y9
E9: x>7, y>9
9 equivalence classes:
(Decision Table
Testing)
Decision-table-based testing
 Decisiontables are a simple formalism to describe how different
combinations of inputs may generate different outputs.

 Decision tables find practical us particularly in data processing


applications. Their tabular form makes them easy to understand and
supports a systematic derivation of tests.

 Applicable to the software requirements written using “if-then”


statements.
Conditions (Causes) and Actions (Effects)
 A CONDITION or CAUSE may be thought of as a distinct input
condition, or an “equivalence class” of input conditions.

 An ACTON or EFFECT may be thought of as a distinct output condition


or change in program state.
Sample of Decision table
o A decision table is consists of a number of
R1 R2 Rm
columns (rules) that comprise all test situations.
o C1 1 1 0
C1, C2..Cn are conditions (Causes)
o A1, A2…An are actions (Effects) C2 1 0 0

o R1, R2,…Rm are Rules (test cases) x x 1

o Action A1 will take place if c1 and c2 are true Cn 0 0 0


(or satisfied)
A1 1 0 0
o 1: means the condition is true.
A2 0 1 1
o 0: means the condition is false.
… 0 0 0
o x: don’t care.
An o o 1
Decision Table Procedure
 1. Identify Conditions and Actions
 2. Deduce Logical Relationships and Constraints
 3. Deduce Logical Relationships and Constraints (cont’d)
 4. Identify an appropriate Test Case Selection Strategy
 5. Construct a Test Case Coverage Matrix
Constraints
Example 1: How to make Decision Base
Table for Login Screen
Interpretation of previous example
 Case 1 – Username and password both were wrong. The user is shown
an error message.
 Case 2 – Username was correct, but the password was wrong. The user
is shown an error message.
 Case 3 – Username was wrong, but the password was correct. The user
is shown an error message.
 Case 4 – Username and password both were correct, and the user
navigated to homepage
Example 2: How to make Decision Table
for Upload Screen
 Now consider a dialogue box which will ask the user to upload photo
with certain conditions like –
 You can upload only '.jpg' format image
 file size less than 32kb
 resolution 137*177.

 Ifany of the conditions fails the system will throw corresponding error
message stating the issue and if all conditions are met photo will be
updated successfully
Decision Table of Previous Example
Problem 1: City-Tax Problem
 The first input is a yes/no response to the question “Do you reside
within the city?” The second input is gross pay for the year in question.
 A non-resident will pay 1% of the gross pay in city tax.

Residents pay on the following scale:


 If gross pay is no more than $30,000, the tax is 1%.
 If gross pay is more than $30,000, but no more than $50,000, the tax is 5%.
 If gross pay is more than $50,000, the tax is 15%.
Problem 2: ATM Withdraw function
A program is written to simulate ATM machine. One of the important
functions of ATM system is the withdraw function. The withdraw function
accepts a specific amount as integer value. The amount must be positive
and within customer balance. Furthermore, the amount should be within
daily limit of withdrawal and must be multiplication of 10.
Problem 3: Car Insurance System
A system function is developed to check if the car is eligible for insurance or not.
The final decision is determined by four factors: car age, car type, car motor and
number of accidents. If the number of accidents exceeds 3 in a year the insurance
is rejected regardless the status of other factors. If car type is Sedan, motor size is
less than 1500cc and age of car is less than 10 years then the car is insured at
standard rate. In previous case, if the motor size is larger than 1500cc then the car
is insured at expensive rate. If the type of car is 4x4 and its age less than 10 years
is insured at special rate regardless of motor size. In any case, if the age of car is
greater than 10 years then the car insurance is rejected.
State transition testing
 Example:
 Let's consider an ATM system function where if the user enters the
invalid password three times the account will be locked.
 In this system, if the user enters a valid password in any of the first three
attempts the user will be logged in successfully. If the user enters the
invalid password in the first or second try, the user will be asked to re-
enter the password. And finally, if the user enters incorrect password
3rd time, the account will be blocked.
Correct PIN Incorrect PIN
S1) Start S5 S2
S2) 1st attempt S5 S3
S3) 2nd attempt S5 S4
S4) 3rd attempt S5 S6
S5) Access Granted - -
S6) Account blocked - -

You might also like