ST Module 4 Full
ST Module 4 Full
Module 4
3
Benefits of ISP
4
ISP
• Input space partitioning describes the input domain of the software
• Domain (D) are partitioned into blocks (b1, b2, .., bn)
5
Partitioning Domains
• Domain D
• Partition scheme q of D
• The partition q defines a set of blocks, Bq = b1 , b2 , … bQ
• The partition must satisfy two properties :
1. blocks must be pairwise disjoint (no overlap)
2. together the blocks cover the domain D (complete)
b1 b2 bi bj = , i j, bi, bj Bq
b3 b=D
b Bq
6
Using Partitions – Assumptions
• Choose a value from each block
• Each value is assumed to be equally useful for testing
• Application to testing
• Find characteristics in the inputs : parameters, semantic
descriptions, …
• Partition each characteristic
• Choose tests by combining values from characteristics
• Example Characteristics
• Input X is null
• Order of the input file F (sorted, inverse sorted, arbitrary, …)
• Min separation of two aircraft
• Input device (DVD, CD, VCR, computer, …)
7
Choosing Partitions
• Choosing (or defining) partitions seems easy, but is easy to get wrong
• Consider the “order of file F”
Solution:
Each characteristic should address just
one property
b1 = sorted in ascending order
b2 = sorted in descending order File F sorted ascending
b3 = arbitrary order - b1 = true
- b2 = false
but … something’s fishy … File F sorted descending
- b1 = true
- b2 = false
What if the file is of length 1?
9
Modeling the Input Domain
• Step 1 : Identify testable functions
• Individual methods have one testable function
• In a class, each method often has the same characteristics
• Programs have more complicated characteristics—modeling documents such
as UML use cases can be used to design characteristics
• Systems of integrated hardware and software components can use devices,
operating systems, hardware platforms, browsers, etc
10
Modeling the Input Domain (cont)
• Step 3 : Model the input domain
• The domain is scoped by the parameters
• The structure is defined in terms of characteristics
• Each characteristic is partitioned into sets of blocks
• Each block represents a set of values
• This is the most creative design step in using ISP
• Step 4 : Apply a test criterion to choose combinations of
values
– A test input has a value for each parameter
– One block for each characteristic
– Choosing all combinations is usually infeasible
– Coverage criteria allow subsets to be chosen
11
Two Approaches to Input Domain Modeling
1. Interface-based approach
• Develops characteristics directly from individual input parameters
• Simplest application
• Can be partially automated in some situations
2. Functionality-based approach
• Develops characteristics from a behavioral view of the program under test
• Harder to develop—requires more design effort
• May result in better tests, or fewer tests that are as effective
12
1. Interface-Based Approach
• Mechanically consider each parameter in isolation
• This is an easy modeling technique and relies mostly on syntax
• Some domain and semantic information won’t be used
• Could lead to an incomplete IDM
• Ignores relationships among parameters
13
2. Functionality-Based Approach
• Identify characteristics that correspond to the intended functionality
• Requires more design effort from tester
• Can incorporate domain and semantic knowledge
• Can use relationships among parameters
• Modeling can be based on requirements, not implementation
• The same parameter may appear in multiple characteristics, so it’s harder to
translate values to test cases
14
15
Steps 1 & 2 – Identifying Functionalities, Parameters and
Characteristics
• A creative engineering step
• More characteristics means more tests
• Interface-based : Translate parameters to characteristics
• Candidates for characteristics :
• Preconditions and postconditions
• Relationships among variables
• Relationship of variables with special values (zero, null, blank, …)
• Should not use program source – characteristics should be based on the input
domain
• Program source should be used with graph or logic criteria
• Better to have more characteristics with few blocks
• Fewer mistakes and fewer tests
16
Steps 1 & 2 : Interface vs Functionality-Based
public boolean findElement (List list, Object element)
// Effects: if list or element is null throw NullPointerException
// else return true if element is in the list, false otherwise
Interface-Based Approach
Two parameters : list, element
Characteristics :
list is null (block1 = true, block2 = false)
list is empty (block1 = true, block2 = false)
Functionality-Based Approach
Two parameters : list, element
Characteristics :
number of occurrences of element in list
(0, 1, >1)
element occurs first in list
(true, false)
element occurs last in list
(true, false)
17
Step 3 : Modeling the Input Domain
• Partitioning characteristics into blocks and values is a very creative
engineering step
• More blocks means more tests
• The partitioning often flows directly from the definition of
characteristics and both steps are sometimes done together
• Should evaluate them separately – sometimes fewer
characteristics can be used with more blocks and vice versa
• Strategies for identifying values :
• Include valid, invalid and special values
• Sub-partition some blocks
• Explore boundaries of domains
• Include values that represent “normal use”
• Try to balance the number of blocks in each characteristic
• Check for completeness and disjointness
18
Interface-Based IDM – TriTyp
• TriTyp, from Chapter 3, had one testable function and three
integer inputs
22
Functionality-Based IDM – TriTyp (cont)
• A different approach would be to break the geometric characterization into
four separate characteristics
25
ISP Criteria – Each Choice
• 64 tests for TriTyp is almost certainly way too many
• One criterion comes from the idea that we should try at least one value from
each block
Each Choice (EC) : One value from each block for each
characteristic must be used in at least one test case.
• Number of tests is the number of blocks in the largest
characteristic Q
Max (B )
i=1 i
For TriTyp: 2, 2, 2
1, 1, 1
0, 0, 0
-1, -1, -1
26
ISP Criteria – Pair-Wise
• Each choice yields few tests – cheap but perhaps ineffective
• Another approach asks values to be combined with other values
28
ISP Criteria – Base Choice
• Testers sometimes recognize that certain values are important
• This uses domain knowledge of the program
Q
1 + i=1 (Bi -1 )
For TriTyp: Base 2, 2, 2 2, 2, 1 2, 1, 2 1, 2, 2
2, 2, 0 2, 0, 2 0, 2, 2
2, 2, -1 2, -1, 2 -1, 2, 2
29
Base Choice Notes
30
ISP Criteria – Multiple Base Choice
• Testers sometimes have more than one logical base choice
Multiple Base Choice (MBC) : One or more base choice blocks are
chosen for each characteristic, and base tests are formed by using each
base choice for each characteristic. Subsequent tests are chosen by
holding all but one base choice constant for each base test and using
each non-base choices in each other characteristic.
• If there are M base tests and mi base choices for each
characteristic:
M + i=1 (M * (Bi - mi ))
Q
Each Choice
Coverage
EC
32
Constraints Among Characteristics
33
Example Handling Constraints
• Sorting an array
Blocks from other
• Input : variable length array of arbitrary type
characteristics are
• Outputs : sorted array, largest value, smallest value
irrelevant
34
Input Space Partitioning Summary
• Fairly easy to apply, even with no automation
• Based only on the input space of the program, not the implementation
35
Problem
• Consider a simple program to classify a triangle. Its
input consists of three positive integers (say x, y, z)
and the data types for input parameters ensures
that these will be integers greater than zero and
less than or equal to 100. The three values are
interpreted as representing the lengths of the sides
of a triangle. The program then prints a message to
the standard output that states whether the
triangle, if it can be formed, is scalene, isosceles,
equilateral, or right-angled
36
• Solution: Following possible boundary conditions are
formed:
• 1. Given sides (A; B; C) for a scalene triangle, the sum
of any two sides is greater than the third and so, we
have boundary conditions A + B > C, B + C > A and A+
C > B.
• 2. Given sides (A; B; C) for an isosceles triangle two
sides must be equal and so we have boundary
conditions A = B, B = C or A = C.
• 3. Continuing in the same way for an equilateral
triangle the sides must all be of equal length and we
have only one boundary where A = B = C.
• 4. For right-angled triangles, we must have A 2+B2= C 2
37
• On the basis of the above boundary conditions, test cases are
designed as follows
38
Functional Testing
• FUNCTIONAL TESTING is a type of software testing that validates
the software system against the functional
requirements/specifications.
• The purpose of Functional tests is to test each function of the
software application, by providing appropriate input, verifying
the output against the Functional requirements.
• Functional testing mainly involves black box testing and it is not
concerned about the source code of the application.
• This testing checks User Interface, APIs, Database, Security,
Client/Server communication and other functionality of the
Application Under Test.
• The testing can be done either manually or using automation.
39
What do you test in Functional Testing?
41
42
43
44
Explain the types of functional testing.
45
Functional Testing Concepts of Howden
• The four key concepts in functional testing are:
➢Precisely identify the domain of each input and
each output variable
➢Select values from the data domain of each
variable having important properties
➢Consider combinations of special values from
different input domains to design test cases
➢Consider input values such that the program under
test produces special values from the domains of
the output variables
46
Different Types of Variables
• Numeric Variables
• A set of discrete values
• A few contiguous segments of values
• Arrays
• An array holds values of the same type, such as integer and real. Individual
elements of an array are accessed by using one or more indices.
• Substructures
• A structure means a data type that can hold multiple data elements. In the
field of numerical analysis, matrix structure is commonly used.
• Subroutine Arguments
• Some programs accept input variables whose values are the names of
functions. Such programs are found in numerical analysis and statistical
applications
47
Howden’s Functional Testing Summary
• Identify the input and the output variables of the program and their
data domains
• Determine the input values that will cause the program to produce
selected outputs as illustrated in Figure 9.5(b).
48
Howden’s Functional Testing Summary
Figure 9.5: Obtaining output values from an input vector (a), and obtaining an input vector from
an output value (b) in functional testing
49