[go: up one dir, main page]

0% found this document useful (0 votes)
43 views60 pages

4 - Test Cases Design Techniques

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 60

TEST CASES DESIGN TECHNIQUES

Agenda

• Test Techniques Overview


• Equivalence Class Partitioning
• Boundary Value Analysis (BVA)
Test Techniques Overview

There are static tests and dynamic tests.


Static tests include inspections and reviews. Specifications review is part of the black box
testing. Do not involve running (executing) the test object

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

Tests Blind for The Code

• 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

Blind for The Code


Black-box Techniques

◆ Black-box techniques are divided into two main subtypes


⬥ Functional
⬥ What the system does?
⬥ Non functional
⬥ How the system does what it does?
Methods for Deriving Test Cases

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

Goals and Advantages

• 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.

● Equivalence Class Partitioning


● Boundary Value Analysis (BVA)
● Decision Table Based Testing
● State Transition Testing

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

• Equivalence partitioning is about testing various groups that we expect


the system to handle the same way

• Exhibiting similar behavior for every single member of an equivalence


partition

• Test cases are designed to cover each partition at least once


Equivalence partitioning

•Equivalence partitioning aims reducing the total number of test cases


to a feasible count
•Excessive testing of all possible input / output values (or conditions)
is usually impossible
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

•Equivalent classes (partitions) are portions of an input or output domain


•The behavior of a component or system is assumed to be the same
for every member of a partition class, based on the specification

A b M 23
4 8 9
j t C
2 56
w
Equivalence partitioning: How to do it?

•The operation of equivalence partitioning is performed by splitting a set (domain)


into two or more disjoint sets
•All the members of each subset share some trait in common
•This trait is not shared with the members of the other subsets
Equivalence partitioning: How to do it?

Subset A

Set
Equivalence
partitioning

Subset B

Choosing a member of each


partition
Equivalence partitioning: How to do it?

•Equivalence partitioning can be iteratively applied to subsets

We no longer have Subset


to choose members A1
from parent sets
Subset EP
Subset
A A2

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

Fill colors Equivalence


green
partitioning

blue
Equivalence partitioning

•Valid equivalence classes


•Describe valid situations
•The system should handle them normally
•Invalid equivalence classes
•Describe invalid situations
•The system should reject them or escalate to the user for
correction or exception handling
Equivalence partitioning

Requirements specifications can be very useful for equivalence partitioning


•For input domains (e.g., an input field): we can refer to the specification
to understand how the system should handle each subset
•For output domains: The specification can be useful for deriving inputs
that should cause the specific output to occur
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

The First Step: Identify the equivalence classes


Divide the input domain into classes of data which make the system
respond in the same way or with the same behavior

Second Step: Derive test cases based on these partitions


● Pick one value from each partition for the complete coverage. Assign a unique number to each class.
● To cover all valid classes, design a new test case until it covers as many as uncovered valid classes.
● To cover all invalid classes, design a new test case covering an invalid class not covered before.
● Notes
○ If multiple invalid classes are tested with the same test, some tests can not be executed because the same
test may mask other tests or terminate the execution of the test case.
○ In theory, only one test case must be written for each equivalence partition.
○ If more than one test case is needed, then you probably need to define a separate partition.
Some Hints for Deriving Equivalence Class

Identify the restrictions and conditions for inputs and outputs according to
the specification
Some Hints for Deriving Equivalence Class

•For every restriction or condition, a partition into equivalence classes are


created upon the type of data:
➢In case of a range (eg: continuous numerical domains)
•Create one valid and two invalid equivalence classes

➢In case of Specific value to be entered


•Create one valid (with all possible correct values)
•Create two invalid equivalence classes (less and more than the correct
number)
Some Hints for Deriving Equivalence Class

➢ In case of a Set of values – each one is treated differently


•Create one valid equivalence class for each value of the set (containing
exactly this one value)
•Create one additional invalid equivalence class (containing all possible
other values)
Some Hints for Deriving Equivalence Class

➢ In case of a Condition or Boolean values that must be fulfilled (true or false).


•Create one valid and one invalid to test the condition fulfilled and not
fulfilled
Can Something Go Wrong?

•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]

Valid Partition → 1 <= no. PO <= 8


Invalid Partition → no. PO > 8 (or no. PO >= 9)
Invalid Partition → no. PO <1 (or no. PO <=0)

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.

Which partitions do you identify?


Lets do an Exercise: Analysis

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.

In summary, for this problem we have found the following partitions:

● Two Partitions for “Free vaccine”: 1 ≤ age ≤ 8; 70 ≤ age


● Two Partitions for “Paid vaccine”: age = 0; 9 ≤ age ≤ 69
● One Invalid Partition: age < 0
● Out of domain: non-integer numbers, characters or boolean.

Now we just need to design 1 test case to cover each partition.


Lets do an Exercise: Answers
Free Vaccine first partition
ID: 0001
Description: Validate the vaccine is provided for free for elderly between 1 and 8 years old.
Pre-Conditions: The user is logged in the application.
Inputs: An integer number between 1 and 8 including those numbers (e.g. 2).
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 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:

# Description Expected Results


1 Open the Vaccine Request form. The form is displayed to the user according mockup_request01.

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:

# Description Expected Results


1 Open the Vaccine Request form. The form is displayed to the user according mockup_request01.

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:

# Description Expected Results


1 Open the Vaccine Request form. The form is displayed to the user according mockup_request01.

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

Now, you can see:

01 - Equivalence partitioning and boundary value analysis

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

• Conceptually, boundary value analysis is about testing the edges of


equivalence classes
Boundary Value Analysis (BVA)
If an operation is performed on a range of numbers:
•Odds are the programmer got it right for the vast majority of the
numbers in the middle,
•But maybe made a mistake at the edges
Boundary Value Analysis (BVA)

If a software can operate on the


edge of its capabilities, it will
almost certainly operate well
under normal conditions
What is a Boundary Value?

An input value or output value that is on the edge of an equivalence partition


•Or at the smallest incremental distance on either side of an edge
•E.g., the minimum or maximum value of a range
What is a Boundary Value?

•The point where the expected behavior of the system changes


•The values could be either input or output ranges of a software component
Valid/Invalid 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

invalid valid 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

An ordered set is one where we can say that one


member is greater than or less than some other
member if those two members are not the same.
Ordered Sets Only

Just because some


item is right above or
below some other item
on a pull-down menu
does not mean that,
within the program, the
two items have a
greater-than/less-than
relationship
Ordered Sets Examples

•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.

It is a variant of the partitioning of equivalence in that instead of selecting any element as


representative of an equivalence class, the values ​that are on the brink of a class is selected.

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

But boundary conditions :


● Use the rule range of values ​for output data
● Use the rule values ​for number of output data
● If the input or output is an ordered set, focus attention on the first and last elements of the set
Boundary Value Analysis (BVA): Guidelines

The partitions are identified examining input specifications as well as outputs

● 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

● Apply guidelines above to output conditions as well


Boundary Value Analysis (BVA): 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]


Invalid Values: 0 >= PO and PO >=9

Valid Partition 1 <= PO <= 8


Invalid Partition PO > 8 (or PO >= 9)
Invalid Partition PO <1 (or PO <=0)

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.

Which partitions and boundary values do you identify?


Lets do an Exercise: Answers

In the previous section we’ve identified these partitions:


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.

So we have found the following partitions:

● Two Partitions for “Free vaccine”: 1 ≤ age ≤ 8; 70 ≤ age


● Two Partitions for “Paid vaccine”: age = 0; 9 ≤ age ≤ 69
● One Invalid Partition: age < 0
● Out of domain: non-integer numbers, characters or boolean.

And the boundary values are: -1, 0, 1, 8, 9, 69, 70


Thank You

You might also like