4 - Test Cases Design Techniques
4 - Test Cases Design Techniques
4 - Test Cases Design Techniques
Agenda
Dynamic tests require the code to be executed. This kind of testing may begin before the
code is 100% finished. For example testing program functions. Involve running
(executing) the test object
Categories of test techniques
Dynamic Test Techniques
Structure Based or White Box Testing - A procedure to derive and/or select test cases based on an
analysis of the internal structure of a component or system. Based on the knowledge of the code,
specifications or other sources of material.
Experienced Based - A procedure to derive and/or select test cases based on tester experience,
knowledge and intuition (functional, technical, business, similar projects, historic bugs, etc.)
Specification Based or Black Box Testing - A procedure to derive and/or select test cases based on
an analysis of the specification of a component or system without reference to its internal structure.
Interested in what the system does, not how it does it. The emphasis is on the control of outputs given
inputs.
Black-box Techniques
• Black-box techniques are a way to derive and select test conditions, test cases, or
test data
• Based on an analysis of the test basis documentation
• Also called specification-based or behavioral techniques
• Tests are based on the way the system is supposed to work
Black-box Techniques
• Black-box testing does not use any information regarding the internal
structure of the component or system to be tested
• The code of the tested object is not considered
• Sometimes it is not accessible
The major goal when applying test cases design techniques is to design tests that
systematically uncover errors with the minimum amount of time and effort
• The exhaustive testing (100%) is impossible! but we need a controlled testing coverage
• Get a good “hit rate”, to find the most errors with the smallest number of test cases
• Offer an approach that can ensure completeness
• Offer the highest likelihood of uncovering errors in software
• Reduce the number of irreproducible Test Cases
• Select the best Test Cases that cover the most scenarios
• Avoid Redundancy and Inconsistency
• All methods complement each other
Test Cases Design Techniques
Each technique requires different effort, but also provides different amounts of
tests with different levels of sophistication.
Note: Decision Table Based Testing and State Transition Testing techniques will
be addressed in future trainings.
Equivalence partitioning
In this method, classes of input conditions called equivalence partitions are identified such
that each member of the class causes the same behavior (same kind of processing and/or
output).
An equivalence class represents a set of valid or invalid states for input condition.
An input condition is:
- a specific numeric value, a range of values
- a set of related values, or a Boolean condition
Advantages
● Is a sophisticated method, more concerned with the values inside of the domain
● Reduces the test cases and increases the effort used to create test cases due to the effort
required to group them in equivalence classes
Equivalence partitioning
•The input / output domain (also called set of interest) is the total set of
data, subject to equivalence partitioning
•A domain can be formed of:
•Input field
•Output field
•Test precondition or postcondition
•Configuration
•Etc. - anything we're interested in testing
Equivalence partitioning
A b M 23
4 8 9
j t C
2 56
w
Equivalence partitioning: How to do it?
Subset A
Set
Equivalence
partitioning
Subset B
Set EP
Subset
A3
Subset
B
Equivalence partitioning: How to do it?
•In a simple drawing program that can fill figures in with red, green, or
blue, you can split the set of fill colors into three disjoint sets:
red
blue
Equivalence partitioning
•There are two common ways an equivalence class can be handled improperly:
•A value is accepted when it should have been rejected (or vice versa)
•A value is properly accepted or rejected but handled in a way appropriate to
another equivalence class (Not the class to which it actually belongs)
Equivalence partitioning
Identify the restrictions and conditions for inputs and outputs according to
the specification
Some Hints for Deriving Equivalence Class
•If the tester chooses the right partitions, the testing will be accurate and efficient
•If the tester mistakenly thinks of two partitions as equivalent and they are not, a
test situation will be missed
•If the tester thinks two objects are different and they are not, the tests will be
redundant
Equivalence partitioning - Examples
Example 1 – Each Area can register a maximum of 8 purchase orders (PO) per month
Valid values: 1, 2, 3, 4, 5, 6, 7, 8 or also written as [1, 8]
Example 2 – In the price field (P) you can enter a positive numeric value with two decimals
Valid Partition → P > 0 (P is a integer)
Valid Partition → P > 0 (P is a real with two decimals)
Invalid Partition → P real with more than two decimals
Invalid Partition → P < = 0
Upon the input condition, alphabetic characters are not admitted in the Price field, so the new Invalid partition defined
is:
Invalid Partition → P is a Char
Lets do an Exercise
The vaccine is given at no cost to children between the ages of 1 and 8 years old and to elderly
people of 70 years of age and above. To the rest, it will be given at $45.
Some of these sentences may sound obvious for you, but following them will help us to identify
the partitions defined in the problem:
● Age is an integer number and it represents the amount of years a person is alive.
● From the date of birth to the day before his/her first birthday a baby has 0 years.
● On their birthday people age’s get increased by 1.
● Therefore children younger than 1 year are 0 years old until the day before their birthday.
● Children older than 8 years are 9 years old from their birthday date to the next birthday.
● People younger than 70 years are 69 years old until the day before their birthday.
● People age is never a negative number.
Lets do an Exercise: Answers
Following that analysis, we can identify these partitions for the given problem:
Lets do an Exercise: Answers
The vaccine is given at no cost to children between the ages of 1 and 8 years old and to elderly
people of 70 years of age and above. To the rest, it will be given at $45.
2 Enter 2 in the age field and fill in all other required information. The value is accepted as valid in the age field.
3 Click on SEND button. A message tells the user “The vaccine is free for the patient”.
Lets do an Exercise: Answers
Free Vaccine second partition
ID: 0002
Description: Validate the vaccine is free for elderly people older than 70 years old.
Pre-Conditions: The user is logged in the application.
Inputs: An integer number greater or equal to 70 (e.g. 85).
Steps and observation points:
2 Enter 85 in the age field and fill in all other required information. The value is accepted as valid in the age field.
3 Click on SEND button. A message tells the user “The vaccine is free for the patient”.
Lets do an Exercise: Answers
Paid Vaccine first partition
ID: 0003
Description: Validate the vaccine costs $45 for babies less than a year old.
Pre-Conditions: The user is logged in the application.
Inputs: 0.
Steps and observation points:
2 Enter 0 in the age field and fill in all other required information. The value is accepted as valid in the age field.
3 Click on SEND button. A message tells the user “The vaccine has a cost of $45 for the patient”.
Lets do an Exercise: Answers
Paid Vaccine second partition
ID: 0004
Description: Validate the vaccine costs $45 for people between 9 and 69 years old.
Pre-Conditions: The user is logged in the application.
Inputs: An integer number between 9 and 69 including those numbers (e.g. 30)..
Steps and observation points:
2 Enter 30 in the age field and fill in all other required information. The value is accepted as valid in the age field.
3 Click on SEND button. A message tells the user “The vaccine has a cost of $45 for the patient”.
Lets do an Exercise: Answers
Negative Age partition
ID: 0004
Description: Validate the system properly rejects a negative age.
Pre-Conditions: The user is logged in the application.
Inputs: Any negative integer (e.g. -5).
Steps and observation points:
# Description Expected Results
1 Open the Vaccine Request form. The form is displayed to the user according mockup_request01.
2 Enter -5 in the age field and fill in all other required information. The age is rejected and the user gets a message to correct the value.
3 Click on SEND button. The button is disabled so the user cannot send bad data to the system.
Similar tests can be designed to avoid data inputs out of domain (e.g. characters).
Testing Basics
Link a youtube
Boundary Value Analysis (BVA)
• Boundary value analysis (BVA) is a black-box test design technique in
which test cases are designed based on boundary values
•If the boundary values are members of a valid equivalence class, they are valid
•If they are members of an invalid equivalence class, they are invalid
…-2-1 0
1 2 3 4 …. …28 29 30
31 32 33 …
Days of a month
Boundary Conditions
•Boundary conditions are the situations at the edge of the planned operational
limits of the software
•Types of data with boundary conditions:
⬥ Numeric
⬥ Character
⬥ Position
⬥ Quantity
⬥ Speed
⬥ Location
⬥ Size
⬥ Etc.
Characteristics of Boundary Conditions
•First/Last
•Start/Finish
•Min/Max
•Over/Under
•Empty/Full
•Shortest/Longest
•Slowest/Fastest
•Soonest/Latest
•Largest/Smallest
•Highest/Lowest
•Next-To/Farthest-From
•Etc.
Ordered Sets Only
•Not all equivalence classes have boundary values!
•Boundary value analysis is an extension of equivalence partitioning
•Applies only when the members of an equivalence class are ordered
Ordered Sets Only
•Ranges of numbers
•How many times something is done
•Size of a number to enter (number of digits)
•Size of a character string
•Size of a file
•Size of a file name
•Amount of available memory
•Speed of data entry (time between keystrokes, menus, etc.)
Boundary Value Analysis (BVA)
This method refines the Equivalence Partitioning. When input values change from one partition
to another, errors are most likely to occur.
The trick is to concentrate the testing effort at the extreme ends of the equivalence classes.
Advantages
● This method requires low effort to develop test cases and its sophistication is low
● The number of test cases generated is high compared with other functional methods
Boundary Value Analysis (BVA): How to do it?
Range
Valid range for extreme cases and invalid cases for the following values to extremes
Number of securities
Maximum, minimum and one above and below these values
Datasets (files)
empty files, first record, last record, treatment of end of file
● If an input condition specifies a range bounded by values a and b, test cases should be
produced with values a, b, as well as just above and just below a and b, respectively
● If an input condition specifies various values, test cases should be produced to exercise
the minimum and maximum values
● If internal program data structures have prescribed boundaries (e.g.: length of some field),
produce test cases to exercise that data structure at its boundary
Boundary Values: 0, 1, 2, 7, 8, 9
Boundary Value Analysis (BVA): Examples
Example 2 – Font Size Menu BVA
Recalling our Exercise
The vaccine is given at no cost to children between the ages of 1 and 8 years old and
to elderly people of 70 years of age and above. To the rest, it will be given at $45.
The vaccine is given at no cost to children between the ages of 1 and 8 years old and to elderly
people of 70 years of age and above. To the rest, it will be given at $45.