Software Testing VIII Sem Unit 3

Embed Size (px)

Citation preview

  • 8/7/2019 Software Testing VIII Sem Unit 3

    1/26

    oftware Testingoftware Testingart A Unit 3art A Unit 3

    Test Generation from Requirements 1

  • 8/7/2019 Software Testing VIII Sem Unit 3

    2/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 2

    Introduction

    Specs Diagrams -Use cases

    Business users

    Analysts/Designers

    Testers

    Design docs

  • 8/7/2019 Software Testing VIII Sem Unit 3

    3/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 3

    Test selection Informalsources

    Requirements

    /Informal Rigourous

    Equivalence Partitioning

    -Boundary value analysis

    -Cause effect graphing

    Decision tables

    Predicate based

    Combinatorial

    Statistical

    Formal

    -Model based techniques

    -Specification based techniques

  • 8/7/2019 Software Testing VIII Sem Unit 3

    4/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 4

    -Te st se le ctio n Pro b le m

    Pe sticid e

    Paradox

    I need to use different pesticides and insecticides to control di

    Testselec

    tiontech

    niquesare

    similarto

    farmersselecting

    variouspe

    sticidesto

    controld

    ifferentty

    pe

  • 8/7/2019 Software Testing VIII Sem Unit 3

    5/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 5

    Equivalence Partitioning

    1 2

    3

    4

    1

    2-1

    2

    3

    4

    E q u iva le n ce p a rtitio n in g w ith d isjo in t a n d o v e rla p p in gsubsets

  • 8/7/2019 Software Testing VIII Sem Unit 3

    6/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 6

    E. P. : Faults TargetedPartitioning input set

    to two regions:

    Expected (E) orlegal

    Unexpected (U) orillegal

    These regions canbe further

    subdivided basedon the expectedbehavior of theapplication

    E

    U

    U

    2U

    1

    E1

    E

    2

    E

    3

  • 8/7/2019 Software Testing VIII Sem Unit 3

    7/2606CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 7

    Relations and E.P.EquivalenceClass

    w fE1 non-null Exists,

    non-emptyE2 non-null DoesntexistE3 non-null Exists,emptyE4 null Exists,non-emptyE5 null DoesntexistE6 null Exists,empty

    Consider a wordcountprogram:

    1.begin

    2. string w, f;

    3. input (w, f);

    4. if (!exists (f)){ raise exception;return 0) };

    5. if (length(w))==0)return 0;

    6. if (empty(f)) return0;

    7. return(getCount(w, f);

    8.end

    . .E P ba sed on b oth req uirem en ts an d

    c o d e

  • 8/7/2019 Software Testing VIII Sem Unit 3

    8/2606CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 8

    E. P. for VariablesKind Equivalence classes Constraint ClassrepresentativesRange One class with values

    inside the range andtwo with valuesoutside

    Speed (60 ..90)

    {(50) , (75),(100)}Area: float

    Area 0{(-2.5) , (32.45) }

    Age: int0 Age

    120

    {{-32) , (65) ,(145) }String At least one legal and

    one illegal string(legal for e.g. aspecified length)

    Fname; string{() , (Kumar) ,(Mary) , (Tom5) ,(Looooong name)

    }

    Vname:string

    {() , (shape) ,(AddrLine2) ,(9pin) ,(Looooong

    variable) }

  • 8/7/2019 Software Testing VIII Sem Unit 3

    9/2606CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 9

    E. P. for Variables: Enumeration &Arrays

    Kind Equivalence classes Constraint Class representativesEnum-eration

    Each value in a separateclass

    Car_color (Silver, Red,Blue, Black)

    Flag: Boolean

    {(Red) , (Blue) ,(Black) }

    {(True) , (False) }

    Arrays Arrays : Legal, Empty &Illegal (larger thanexpected size)

    Java array:int [] aName =new int [3];

    {[] }, {[-10, 20] }, {[-23, 0, 56, -34, 3]}

  • 8/7/2019 Software Testing VIII Sem Unit 3

    10/2606CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 10

    E. P. : Examples

    Grade calculationA: >= 75, B: >= 65, C: >= 60, D: >= 50, E: 7E4: 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> 9E4: 3 x 7, y < 5, E5: 3 x 7, 5 y 9,

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

    y > 9

    A i d f

  • 8/7/2019 Software Testing VIII Sem Unit 3

    12/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 12

    A systematic procedure forE. P.

    1.Identify the input domain2.Equivalence classing

    3.Combine equivalence classes

    4.Identify infeasible equivalence classes

  • 8/7/2019 Software Testing VIII Sem Unit 3

    13/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 13

    =S V x F x cm d xtem pch

    :S a m p le va lu e s{ , , , - }GUI _ temp 5{ , , , }GUI _ c ancel _

    { , , , }file cmd_file shut _

    E.g.: E. P. on a control systemsoftware

    ( )C o n tro lS o ftw a re C S

    G U I

    V{ , }GUI file

    F C

    cmd

    ( , , )temp cancel shut

    Tempch{- , - , , }10 5 5 10

    Data file

    T t l ti b d E

  • 8/7/2019 Software Testing VIII Sem Unit 3

    14/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 14

    Test selection based on Eq.ClassesID Equivalence class{(V, F, cmd, tempch)} Test data(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)

    T t l ti b d E

  • 8/7/2019 Software Testing VIII Sem Unit 3

    15/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 15

    Test selection based on Eq.ClassesID Equivalence class{(V, F, cmd, tempch)} Test data(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)

  • 8/7/2019 Software Testing VIII Sem Unit 3

    16/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 16

    GUI Design and Eq. Classes

    A p p lica tio n

    12

    Correc

    tvalues

    Correct values

    Application Application

    2

    Correc

    tvalues

    -GUI A -GUI B

    Protects llvariables

    againstincorrect

    values

    Protects somevariables

    againstincorrect

    values

    Both valid andinvalid values for

    all variables areallowed

    B d V l A l i

  • 8/7/2019 Software Testing VIII Sem Unit 3

    17/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 17

    Boundary-Value Analysis(BVA)

    Test-selection technique that targets faults inapplications at the boundaries of equivalenceclasses

    Test selection using BVA is usually done in

    conjunction with EP

  • 8/7/2019 Software Testing VIII Sem Unit 3

    18/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 18

    Boundary Value Analysis

    Test selection using BVA from input domain:Partition the input domain using

    unidimensional partitioning (Alternately,single partition of multidimensionallypartitioned input domain)

    Identify the boundaries for each partition (Canalso be identified using special relationshipsamong inputs)

    Select test data such that each boundaryvalue occurs in at least one test input

  • 8/7/2019 Software Testing VIII Sem Unit 3

    19/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 19

    BVA: Examples

    98 100 9981000

    _____*__x__*____________*__x__*_______E3

    Item code

    0 2 99101

    _____*__x__*____________*__x__*_______

  • 8/7/2019 Software Testing VIII Sem Unit 3

    20/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 20

    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), }

  • 8/7/2019 Software Testing VIII Sem Unit 3

    21/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 21

    BVA: Observations

    Relationships among inputs variables must beexamined carefully when identifyingboundaries along the input domain

    This examination may lead to boundaries that

    are not evident from eq. classesAdditional tests may be obtained when using a

    partition of the input domain obtained bytaking the product of eq. classes created

    using individual variables

  • 8/7/2019 Software Testing VIII Sem Unit 3

    22/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 22

    Category-Partition Method

    A systematic approach to generation of testsfrom requirements

    Consists of mix of manual and automatedsteps

    As the name suggests, it is identifying the testsbased on certain category

  • 8/7/2019 Software Testing VIII Sem Unit 3

    23/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 23

    Steps in C-P method

    A n a ly ze S p e cifica tio n

    Id e n tify C a te g o rie s

    Pa rtitio n ca te g o rie s

    Identify constraints

    ( )Re write test specification

    Pro ce ss sp e cifica tio n

    /E va lu a te g e n e rato r o p

    G e n e ra te te st scrip ts

    Fu n ctio n a lsp e cifica tion

    Fu n ctio n a l

    u n its

    C a te g o rie s

    C h o ice s

    C o n stra in ts

    Te st sp e c

    ( )TS

    Te st fra m e s

    :R e vise T SN o

    Te st fra m e s

    Test scrip ts

    1

    2

    3

    4

    5

    6

    7

    8

    R e v ise:T S

    Ye s

  • 8/7/2019 Software Testing VIII Sem Unit 3

    24/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 24

    C-P Method: Example

    findPrice function: Takes 3 inputs code, qty &weight

    Leftmostdigit

    Interpretation Remarks

    0 Ordinary grocery itemssuch as rice, bread,

    magazine & soaps

    Value ofweightis ignored

    2 Variable-weight items

    such as grains, fruits &vegetables

    Value ofqty is ignored

    3 Health-related items suchas Vicks, Crocin, Band-aid

    Value ofweightis ignored5 Coupon; digit 2 (dollars),

    3 and 4 (cents) specify thediscount

    Qty is the value of thediscount1, 6-9 Unused

  • 8/7/2019 Software Testing VIII Sem Unit 3

    25/26

    06CS842/IS81 SOFTWARE TESTING/RVH/SDMIT 25

    Writing test specificationParametersCode

    Length Valid Invalid [error]

    Leftmost digit 0 [property

    Ordinarygrocery]

    2 [Variable-weight 3 [Health-related 5 [Coupon] Remaining digits

    Valid string[single]

    Invalid stringerror

    QtyValid qty [if

    ordinary grocery]Invalid qty[error]

    WeightValid weight [ifvariable-weight

    Invalid weight[error]

    EnvironmentsDatabase:

    Item exists Item doesnt exist

    [error]

  • 8/7/2019 Software Testing VIII Sem Unit 3

    26/26

    nd of Partnd of Part nitnit 33Unit 4 Test Generation from Requirements 2

    Continued in another PPT