Sie sind auf Seite 1von 26

Software Testing

Part A – Unit 3
Test Generation from Requirements – 1
Introduction
Requirements
Business users

Use- Design
Specs Diagrams cases
Analysts / docs
Designers

Generation of
tests from
Test cases informally as
Testers well as rigorously
specified
requirements
06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 2
Test selection – Informal sources
Requirements

Informal/Rigourous

Equivalence
Predicate based
Partitioning
Boundary-value
Combinatorial
analysis
Cause-effect
Statistical
graphing

Decision tables
Model-based
techniques
Formal
Specification-
based techniques

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 3


Test-selection Problem
Consider a pay-roll processing
system taking following inputs: I need to use different
n iq ues
n tech ers pesticides and
t io
Emp. ID: int : 3 digits: 0 to 999 st selec t o farm ides insecticides to control
Te ila r estic s
Emp. Name: string: 20 chars s im s p different kinds of pests
are v ariou ent type
(alphabets & space char) tin g er & insects …
Rate: float: $5 to $10 per hr selec ntrol diff ts
to co s
(rates are in multiples of of pe
quarters)
HrsWorked: int: 0 to 60

Each element of input domain is a


record containing all 4 items above.
So, the no. of possible records is:

999 x 2720 x 21 x 61 ≈ 5.42 x 1034


i.e. 6273 crore x 1010 years if one test
Pesticide Paradox
case is carried out in 1 ns!!!
06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 4
Equivalence Partitioning

1-2
1 2 2
1
3 3

4 4

Equivalence partitioning with disjoint and overlapping subsets

Test selection using “Equivalence partitioning” allows tester to subdivide


the input domain into relatively smaller no. of sub-domains.

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 5


E. P. : Faults Targeted
U Partitioning input set to
U2 two regions:
Expected (E) or legal
U1
Unexpected (U) or illegal
E1 E3 These regions can be
E2 further subdivided based
E on the expected behavior
of the application

No. of faults these tests are able to expose


Effectiveness of tests generated =
Total no. of faults lurking (lying) in

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 6


Relations and E.P.
Equivalence w f Consider a wordcount
Class
E1 non-null Exists, non-
program:
empty 1. begin
E2 non-null Doesn’t 2. string w, f;
exist 3. input (w, f);
E3 non-null Exists,
empty 4. if (!exists (f))
{ raise exception;
E4 null Exists, non-
empty return 0) };
E5 null Doesn’t 5. if (length(w))==0)
exist return 0;
E6 null Exists, 6. if (empty(f))
empty return 0;
7. return(getCount(w,
f);
E. P. based on both requirements and code 8. end

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 7


E. P. for Variables
Kind Equivalence classes Constraint Class
representatives
Range One class with values Speed є (60 .. {(50) , (75),
inside the range and two 90) (100)}
with values outside
Area: float {(-2.5) , (32.45) }
Area ≥ 0
Age: int {{-32) , (65) ,
0 ≤ Age ≤ 120 (145) }
String At least one legal and one Fname; string {(є) , (Kumar) ,
illegal string (legal for e.g. (Mary) , (Tom5) ,
a specified length) (Looooong name) }
Vname: string {(є) , (shape) ,
(AddrLine2) ,
(9pin) , (Looooong
variable) }

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 8


E. P. for Variables: Enumeration & Arrays
Kind Equivalence classes Constraint Class
representatives
Enum- Each value in a Car_color є {(Red) , (Blue) ,
eration separate class (Silver, Red, (Black) }
Blue, Black)
Flag: Boolean {(True) , (False) }
Arrays Arrays : Legal, Empty Java array: {[] }, {[-10, 20] },
& Illegal (larger than int [] aName = {[-23, 0, 56, -34, 3]}
expected size) new int [3];

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 9


E. P. : Examples
Grade calculation
A: >= 75, B: >= 65, C: >= 60, D: >= 50, E: < 50

Insurance premium calculation


Inputs:
 Sum assured (Rs 25,000 to 1 crore)
 Gender: Male or Female

 Age (1 to 120 yrs with subcategories: 1-40, 41-60, 60-120)

 Term (3 to 25 yrs)

 Type (IP1, IP2, IP3)

Setting wake-up alarm in a mobile phone


06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 10
EP: Unidimensional Vs. Multidimensional
Partitioning the input set considering one input a time –
unidimensional
Considering multiple variables: Multidimensional
E.g. 3 ≤ x ≤ 7 and 5 ≤ y ≤ 9
Equivalence classes:
E1: x < 3 E2: 3 ≤ x ≤ 7 E3: x > 7
E4: y < 5 E5: 5 ≤ y ≤ 9 E6: y > 9
Multidimensional input set:
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: x > 7, y < 5, E8: x > 7, 5 ≤ y ≤ 9, E9: x > 7, y > 9

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 11


A systematic procedure for E. P.
1. Identify the input domain
2. Equivalence classing
3. Combine equivalence classes
4. Identify infeasible equivalence classes

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 12


E.g.: E. P. on a control system software
V F C
{GUI, file}

cmd
(temp, cancel, shut) GUI
Control Software (CS)
Tempch
{-10, -5, 5, 10}

S = V x F x cmd x tempch

Data file Sample values:


{GUI, _, temp, -5}
{GUI, _, cancel, _}
{file, cmd_file, shut, _}

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 13


Test selection based on Eq. Classes
ID Equivalence class Test data
{(V, F, cmd, tempch)} (V, F, cmd, tempch)
E1 {(GUI, f_valid, temp, t_valid)} (GUI, a_file, temp, -10)
E2 {(GUI, f_valid, temp, t_valid)} (GUI, a_file, temp, -5)
E3 {(GUI, f_valid, temp, t_valid)} (GUI, a_file, temp, 5)
E4 {(GUI, f_valid, temp, t_valid)} (GUI, a_file, temp, 10)
E5 {(GUI, f_invalid, temp, t_valid)} (GUI, a_file, temp, -10)
… … …
E8 {(GUI, f_invalid, temp, t_valid)} (GUI, a_file, temp, 10)
E9 {(GUI, _, cancel, NA)} (GUI, a_file, cancel, -5)
E10 {(GUI, _, cancel, NA)} (GUI, no_file, cancel, -5)

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 14


Test selection based on Eq. Classes
ID Equivalence class Test data
{(V, F, cmd, tempch)} (V, F, cmd, tempch)
E11 {(file, f_valid, temp, t_valid)} (file, a_file, temp, -10)
… … …
E14 {(file, f_valid, temp, t_valid)} (file, a_file, temp, 10)
E15 {(file, f_valid, temp, t_invalid)} (file, a_file, temp, -25)
E16 {(file, f_valid, temp, NA)} (file, a_file, shut, 10)
E17 {(file, f_invalid, NA, NA)} (file, no_file, shut, 10)
E18 {(undefined, _, NA, NA)} (undefined, no_file, shut, 10)

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 15


GUI Design and Eq. Classes

2 2

1
Correct
Correct Correct
values
values values

GUI-A GUI-B

Application Application Application


Both valid and Protects all Protects some
invalid values for all variables against variables against
variables are allowed incorrect values incorrect values

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 16


Boundary-Value Analysis (BVA)
Test-selection technique that targets faults in
applications at the boundaries of equivalence classes
Test selection using BVA is usually done in
conjunction with EP

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 17


Boundary Value Analysis
Test selection using BVA from input domain:
Partition the input domain using unidimensional
partitioning (Alternately, single partition of
multidimensionally partitioned input domain)
Identify the boundaries for each partition (Can also be
identified using special relationships among inputs)
Select test data such that each boundary value occurs in
at least one test input

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 18


BVA: Examples
98 100 998 1000
_____*__x__*____________*__x__*_______
<- E1 99 E2 999 E3 ->
Item code

0 2 99 101
_____*__x__*____________*__x__*_______
<- E4 1 E5 100 E6 ->
Qty
06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 19
BVA: Test set
T = { t1 : (code = 98, qty = 0),
t2 : (code = 99, qty = 1),
t3 : (code = 100, qty = 2),
t4 : (code = 998, qty = 99),
t5 : (code = 999, qty = 100),
t6 : (code = 1000, qty = 101),
}

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 20


BVA: Observations
Relationships among inputs variables must be
examined carefully when identifying boundaries along
the input domain
This examination may lead to boundaries that are not
evident from eq. classes
Additional tests may be obtained when using a
partition of the input domain obtained by taking the
product of eq. classes created using individual
variables

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 21


Category-Partition Method
A systematic approach to generation of tests from
requirements
Consists of mix of manual and automated steps
As the name suggests, it is identifying the tests based
on certain category

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 22


Steps in C-P method
Functional
specification
Analyze (Re)write test
1 5
Specification specification
Functional units Test spec (TS)
Identify Process
2 6
Categories specification
Categories Revise TS: Test frames
Partition Yes Evaluate
3 categories 7 generator o/p
Revise TS: No
Choices
Test frames
Identify Generate test
4 constraints 8 scripts
Constraints Test scripts
06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 23
C-P Method: Example
findPrice function: Takes 3 inputs – code, qty & weight
Leftmost Interpretation Remarks
digit
0 Ordinary grocery items such as Value of weight is ignored
rice, bread, magazine & soaps
2 Variable-weight items such as Value of qty is ignored
grains, fruits & vegetables
3 Health-related items such as Value of weight is ignored
Vicks, Crocin, Band-aid
5 Coupon; digit 2 (dollars), 3 Qty is the value of the discount
and 4 (cents) specify the
discount
1, 6-9 Unused

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 24


Writing test specification
Parameters Qty
Code Valid qty [if
Length ordinary grocery]
 Valid Invalid qty [error]
 Invalid [error] Weight
Leftmost digit Valid weight [if
0 [property Ordinary variable-weight
grocery]
Invalid weight [error]
2 [Variable-weight
3 [Health-related Environments
5 [Coupon] Database:
 Remaining digits  Item exists
 Valid string [single]  Item doesn’t exist [error]
 Invalid string [error]

06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 25


End of Part – A Unit – 3
Unit 4 – Test Generation from Requirements – 2
Continued in another PPT …

Das könnte Ihnen auch gefallen