3100-topic6

download 3100-topic6

of 72

Transcript of 3100-topic6

  • 8/17/2019 3100-topic6

    1/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 1

    Topic 6:

    Verification: Testing and Analysis

    Yor !a"e: ##################### 

    Co"pter Science $ Engineering Depart"ent

    The Chinese University of %ong &ong

    Software Engineering

  • 8/17/2019 3100-topic6

    2/72

     © Chinese University, CSE Dept. Software Engineering / 6 - '

    The Need for Verification

    ♦The pro(ct of any engineering activity "st)e verifie( *shown to )e correct+ accor(ing to

    its reire"ents throghot its (eveop"ent.

    ♦erifying s/w is perhaps "ore (iffict thanverifying other engineering pro(cts

    ♦Software verification an( vai(ation *$+ cost

    0 or "ore of the whoe software

    (eveop"ent

  • 8/17/2019 3100-topic6

    3/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 2

    The Need for Verification

    ♦erification 3 4re we )i(ing the pro(ct right5 )ase( on reire"ents *(oc"ents+

    “辨证”

    ♦  ai(ation 3 4re we )i(ing the right pro(ct5)ase( on csto"ers *rea sers+

    “確認”

    ♦Co"parison: ####################### 

  • 8/17/2019 3100-topic6

    4/72

     © Chinese University, CSE Dept. Software Engineering / 6 -

    Goals and Requirements of Verification 

    1+ Everything "st )e verifie( 3 erifying: - co(e

    - spec *si"ation or property anaysis+

    - process

    - the verification itsef 

    - software aity *porta)iity, n(erstan(a)iity,perfor"ance, etc+

     3 erification "ay )e perfor"e(

    - at (ifferent points of ti"e

    - )y (ifferent peope- with (ifferent goas

    - )y sing (ifferent technies

  • 8/17/2019 3100-topic6

    5/72

     © Chinese University, CSE Dept. Software Engineering / 6 -

    Goals and Requirements of Verification

    '+ The rests of verification "ay not )e )inary 3 not "erey a 7yes or no8 rest

     3 pro(ct correctness *co"piance with

    fnctiona spec+ is a "atter of ########## 

    1. The presence of (efects in arge an( co"pe9

    software cannot )e avoi(e( co"petey

    '. So"e (efects can )e toerate( *7##########8+

    2. Correctness is reative, )t har( to "easre

     3 other s/w aity, e.g. efficiency, has severa

    eves

  • 8/17/2019 3100-topic6

    6/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 6

    Goals and Requirements of Verification

    2+ erification "ay )e o)ective or s)ective 3 ;)ective verification: perfor"ing a test (ata

    "easring the response ti"e< correctness <

    reia)iity

     3 S)ective verification:

    = >orta)iity

    = ?aintaina)iity

    = @esa)iity

    = Un(erstan(a)iity

    = User-frien(iness

    A:

    B:

     __ 

     __ 

     __ 

     __ 

     __ 

  • 8/17/2019 3100-topic6

    7/72

     © Chinese University, CSE Dept. Software Engineering / 6 - A

    Goals and Requirements of Verification

    + Even i"picit aities "st )e verifie(

    ♦ *nspecifie(+ perfor"ance reire"ent

     3 7co""on sense8

     3 try to antify it♦ ?aintaina)iity

     3 har( to antify

     3 asB the estion 7how, when, an( why the s/w

    pro(cts are iBey to ##############8

  • 8/17/2019 3100-topic6

    8/72

  • 8/17/2019 3100-topic6

    9/72

     © Chinese University, CSE Dept. Software Engineering / 6 -

    Testing: General !ssues

    ♦Testing is the "ost natra an( csto"ary wayof verifying software

    ♦F"possi)e to test software n(er a possi)e

    operating con(itions♦!ecessary to fin( sita)e test cases

    ♦s/w acBs the continity property< s"a

    (ifferences in operating con(itions "ay rest

    in (ra"aticay (ifferent )ehaviors

  • 8/17/2019 3100-topic6

    10/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 10

    ♦ Fnherent co"pe9ity of software♦Constrcting an operationa environ"ent for testing

    prpose is har(

    ♦ Fntracta)e an( n(eci(a)e natre of testing

    ♦ F(iosyncrasy of software

     3 Errors "anifest the"seves in rare states, yet crciay

    i"portant. “If anything can go wrong, it will!” 

     3Trivia cerica errors can have "aor conseences *e.g.,E9a"pe in ne9t si(e+.

    "hat #a$es Testing So %ifficult&

  • 8/17/2019 3100-topic6

    11/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 11

    A Testing E'amle

    Example 6.1 Consider the following binary search procedure:

     procedure binary-search(key: in element; table: in elementTable; found: out Boolean)

     begin

    bottom := table’first;

    top := table’last;

     while bottom < top loop

    if (bottom + top) rem ≠ ! then

    middle := (bottom + top " #) $;else

    middle := (bottom + top)$;

    endif;

    if key % table(middle) then

    top := middle;

    else

    bottom := middle + #;

    endif;

    endloop;

    found := key = table(middle);

    end  binary-search;

    a su(tle (ug )*

  • 8/17/2019 3100-topic6

    12/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 1'

    Goals for Testing

    1+ >rogra" testing can )e se( to show the ########### of )gs, not their ########### 

    '+ The "ost natra approach of #############testing is so"eti"es inappropriate

    e+g+ read(&);

    read(y);

    if &=y then ' := ;

      else ' := !;endif;

    rite(');

    ,*

    -hard to detect (y_______________.

  • 8/17/2019 3100-topic6

    13/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 12

    Goals for Testing

    2+ Testing sho( hep ocate errors, not st (etectthe"

     3 Testing ⇒ (e)gging

    + Testing sho( )e repeata)e 3 not trivia

     3 rests "ay )e infence( )y ############ 

    e+g+ if & = ! then rite(abnormal*);

    else rite(normal*);

    endif; 3 "ore critica with concrrent s/w

  • 8/17/2019 3100-topic6

    14/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 1

    Goals for Testing

    + Testing sho( )e accratei. n"erica precision

     ########################## 

    ii. ti"ing accracy

    which are specification (epen(ent

    6+ Gor"a specifications e9press correctness criteria

    na")igosy to enhance testing accracy 3 e.g.,for all i(# % i < n) implies ( a(i) % a(i+#)),

  • 8/17/2019 3100-topic6

    15/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 1

    Theoretical /oundations for Testing

    >: a progra"

    D: >Hs ######### (o"ain (1,(

    ' ∈ D

    @: >Hs ########## range r  1,r 

    ' ∈ @

    @H: >Hs otpt range which (oesnHt satisfy ########### 

    >*(+: the rest of e9ecting > on inpt (

    * >*(1+ I r 

    1, >*(

    '+ I r 

    ' +

    ;@: ########################## 

    Gigre 6.1 Concepta Gra"eworB in >rogra" Testing

    0

    %

    R  R1

    d2 d3

    r 3

    r 2

  • 8/17/2019 3100-topic6

    16/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 16

    Theoretical /oundations for Testing

    > is correct for ( iff ######################## 

    e.g., >*(1+ satisfies ;@, >*(

    '+ (oes not

    > is correct iff ############################# 

    Jhat (oes it "ean )y 7incorrect85

    - ############: incorrect s/w (esign or co(e *7)g8+

    - ############: erroneos progra" state pro(cing

    otpt which (oes not satisfy ;@

     _______________________________ 

    0

    %

    R  R1

    d2 d3

    r 3

    r 2

  • 8/17/2019 3100-topic6

    17/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 1A

    Theoretical /oundations for Testing

    ♦ !ote1+ test case 3 an ee"ent ( of D

    '+ test set T 3 a finite set of test cases

    2+ sccessf 3 T is sccessf for > if > is #######

    for T *for a test cases in T+

    + i(ea 3 T is i(ea if whenever > is incorrect, ∃(

    ∈T → > is ########## for ( *T is ###########

    for >+

    { }nd d d T    4+++4 32=

  • 8/17/2019 3100-topic6

    18/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 1

    Theoretical /oundations for Testing

    + test case criterion C 3 a s)set of 'DG,'DG: the set of a finite s)sets of D

    e+g+4 5A , 6 7'24'3484'n* 9 n ≥  and

    e'ists i4;4$ -'i 7

  • 8/17/2019 3100-topic6

    19/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 1

    Theoretical /oundations for Testing

    6+ ############# 3 C is consistent if, ∀T1,T' ∈ C,T1 is sccessf iff T' is sccessf

    A+ ############# 3 C is co"pete if, whenever > is incorrect, ∃T1 

    ∈ C → T1 is nsccessf

    = Si"iar to 7i(ea8 ⇒ 

    7##############################################8

    e.g. The )inary search progra" in E9a"pe 6.1 worBs propery ony if

    the ength of the seence is a power of two.

    Ket (i: ength of the seence is i, then

      52 , 6 7d*4 7d4d@*4 7d4dC* =

    53 , 6 7d4d4dD*4 7d34d@4dC* =

  • 8/17/2019 3100-topic6

    20/72

     © Chinese University, CSE Dept. Software Engineering / 6 - '0

    Theoretical /oundations for Testing

    + ########### 3 C1 is finer than C' if, for any >,∀T1∈ C1, ∃T' ⊆ T1 → T' ∈ C' ∧

    ∀T'∈ C', ∃T1 ⊇ T' → T1 ∈ C1∧ C1 L C'

     ________________________________________ 

    e+g+

    5B , 67'24'34 84 'n* 9 n ≥ 3 and e'ists i4;

    -'i 7

  • 8/17/2019 3100-topic6

    21/72

     © Chinese University, CSE Dept. Software Engineering / 6 - '1

    Theoretical /oundations for Testing

    + ############### 3 C1 is "ore trsta)e than C' if >is incorrect then M *∃ T' ∈ C' → T' is nsccessf on

    > and ∃ T1 ∈ C1 → T1 sccessf on >+

    = Ff C1 is "ore trsta)e than C', then C' cannot have a test set

    which is nsccessf whie C1 has a test set which issccessf

    = N: if C1 is finer than C' then C1 is "ore trsta)e than C'5

    A: _________+ E+g+4

    { }{ }>

  • 8/17/2019 3100-topic6

    22/72

     © Chinese University, CSE Dept. Software Engineering / 6 - ''

    Emirical Testing 0rinciles

    1+ E9hastive testing is i"possi)e< we nee( testingstrategies to seect ######### test cases with high

    potentia to ncover error 

    '+ Fncreasing the n")er of test cases ########

    necessariy increase the significance F  e+g+4 if ' * y then

    ma' :, '

    else

    ma' :, y → error: y (ecomes another sym(ol

    endif

    T2: 6 -43.4 -34. = uncoHers the error 

    T3: 6 -43.4 [email protected] -42. = does not

  • 8/17/2019 3100-topic6

    23/72

     © Chinese University, CSE Dept. Software Engineering / 6 - '2

    Emirical Testing 0rinciles

    2+ Orop the inpt (o"ain into casses, schthat ee"ents of a given cass )ehave the

    sa"e way

     F  Ine test case → _____________ 

    + ########################: D I ∪DF are

    those casses, where D is the inpt (o"ain

    %2

    %3 %

    %@

    8

    D

  • 8/17/2019 3100-topic6

    24/72

     © Chinese University, CSE Dept. Software Engineering / 6 - '

    Emirical Testing 0rinciles

    + To satisfy this principe:i. Ff Di are (isoint casses, i.e., Di ∩ D : I φ, i≠ , we

    choose one test case fro" each Di

    + Ff Di∩ D : ≠ φ, a test case in Di∩ D : e9ercises )oth

    Di an( D : 

    e+g+4  %2 , 6 di 9 di mod 3 ,

  • 8/17/2019 3100-topic6

    25/72

     © Chinese University, CSE Dept. Software Engineering / 6 - '

    Emirical Testing 0rinciles

    6+ The co"pete coverage principe hepsappro9i"ate ########### an(

     ########### criteria+ 

    Testing in the S"a vs Testing in the Karge

  • 8/17/2019 3100-topic6

    26/72

     © Chinese University, CSE Dept. Software Engineering / 6 - '6

    Testing in the Small

    ♦ )acB-)o9 testing

    1. ####################

    '. (erive test cases prey )ase( on the spec

     3 spec-)ase( test case (eveop"ent

    2. test what the progra" is sppose( to (o *for a

     ########### fnctions+♦ white-)o9 testing

    1. ################### 

     3 ooB at the progra" strctre (ring testing

    '. sing infor"ation a)ot the interna strctre to (erive testcases

     3 strctre-)ase( test case (eveop"ent

    2. test what the progra" (oes *any ######## fnctions5+

  • 8/17/2019 3100-topic6

    27/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 'A

    "hite)Bo' Testing

    ♦ Gor test seection criteria *C0,C1,C',C2+ 3 E9a"pe 6.': Consi(er the we-Bnown agorith" of Eci( begin

    read(&);

    read(y);

     while & ≠ y loop

    if & y then

    & := & " y;

    else

    y := y " &;

    endif;

    end loop;

    return(&);

    end;

     3 Seect test cases P Q9I2,yI2R, Q9I,yI2R, Q9I2, yIR

    IR state"ent coverage criterion

    J:

    if ' * y

    e'it

    ',y

    while

    '≠y

    entry

  • 8/17/2019 3100-topic6

    28/72

     © Chinese University, CSE Dept. Software Engineering / 6 - '

    Statement)5oHerage 5riterion

    ♦Seect a test set T sch that everyee"entary ######### in > is e9ecte( at

    east once )y so"e ( in T

     3 an inpt (at" e9ectes "any state"ents

     3 try to "ini"ie the n")er of test cases whie

    sti preserving the (esire( coverage

  • 8/17/2019 3100-topic6

    29/72

     © Chinese University, CSE Dept. Software Engineering / 6 - '

    E'amle

    read (x); read (y);

    if x > 0 thenwrite ("1");

    else

    write ("2");end if;

    if y > 0 thenwrite ("3");

    elsewrite ("4");

    end if; 

    {, ,

    , }covers all statements

    {, }is minimal (two test cases)

    " $ f h 5 i i

  • 8/17/2019 3100-topic6

    30/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 20

    "ea$ness of the 5riterion

    if x ≠ 0 then

    x := -x;end if;

    z := 1.0/x;

    {x=3} covers allstatements

    it does not exercise thecase when x is ______ where the __________  branch is not entered

    5 t l /l G h G f 0 0

  • 8/17/2019 3100-topic6

    31/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 21

    5ontrol /low Grah G  for 0rogram 0

    Gigre 6.1

    O1 O' O1 O1

    O1

    O'

    a+ entry )+ if-then ese c+ if (+ repeat /whie e+ seence

    Gigre 6.' Constrction of the contro-fow graph of a progra"

    5 t l /l G h G f 0 0

  • 8/17/2019 3100-topic6

    32/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 2'

    5ontrol /low Grah G  for 0rogram 0

    a. !KI rocedural call (. if cond then S2 _______ 

    else S3    _______ 

    endif

    c. if cond then S2

    d. while cond loo

    S2

    endloo

    e. S2

    S3) Sequential nodes may (e considered as only one node tosimlify the control flow grah

    5ontrol /low Grah G for 0rogram 0

  • 8/17/2019 3100-topic6

    33/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 22

    5ontrol /low Grah G  for 0rogram 0

    L  __________ -circle. F one or more rocedural statements-sequential statements can (e lumed together.

    L  __________ -arrow. F flow of control

    L  __________ F area (ounded (y edges and nodes -include the area

    outside the grah.

    L  __________ node F the node which contains a conditional

    statement

    5ontrol /low Grah G for 0rogram 0

  • 8/17/2019 3100-topic6

    34/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 2

    5ontrol /low Grah G  for 0rogram 0

    no(es:############### 

    e(ges:############### 

    pre(icate no(es: ####### 

    regions:############## 

      ######## 

    I ######## 

    I ######## 

    I *O+

    if ' * y

    e'it

    ',y

    while

    '≠y

    entry

    # 5 ( 1 Th

  • 8/17/2019 3100-topic6

    35/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 2

    #c5a(e1s Theory

    #c5a(e1s cyclomatic comle'ity V-G.

    2. V-G. , e F n M 3 F "here in the control flow grah

    e: num(er of edges

    n: num(er of nodes V-G.: the num(er of linearly indeendent aths in a rogram -the

    num(er of conditions lus one4 if no GITIs.

    for each module V-G.: _________ good structureuer (ound  ____________

    3. V-G. , of regions. V-G. , of redicate nodes M 2

    5 : Edge 5oHerage 5riterion

  • 8/17/2019 3100-topic6

    36/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 26

    52: Edge 5oHerage 5riterion

    ♦Seect a test set T sch that, )y e9ecting >for each ( in T, each e(ge of >Hs contro fow

    graph is traverse( at east once

     3 4 #################### path: 4ny path throgh

    the progra" that intro(ces a new e(ge coverage

    ♦!ote: pro)e" "ay arise for co"pon(

    ooean e9pressions, e.g. *if  C1 and C' or  C2 

    V.+, where CiHs, 7constitents8, not a teste(

    5 : Edge 5oHerage 5riterion

  • 8/17/2019 3100-topic6

    37/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 2A

    52: Edge 5oHerage 5riterion

    .&ample /01:

    found := false;

    if number2of2items ≠ ! then counter := #;

     while (not found) and  counter ≤ number2of2items loop

    if table(counter)= desired2element then

    found := true;

    endif;

    counter := counter + #;

    endloop;

    endif;

    if found then rite

    (the desired element e&ists0*);else rite(the desired

    element does not e&ist0*);

    endif; 

    Searching an ee"ent

    2+ _____________________________ 

    3+ ________________________________

     ________________________________

     _______________________ 

    + ________________________________

     ________________________________

     _______________________ 

    5 : 5ondition 5oHerage 5riterion

  • 8/17/2019 3100-topic6

    38/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 2

    53: 5ondition 5oHerage 5riterion

    ♦Seect a test set T sch that each e(ge of >Hscontro fow graph is traverse(, an( a

    possi)e vaes of the constitents of

    co"pon( con(itions are e9ercise( at east

    once.

    5 : 5ondition 5oHerage 5riterion

  • 8/17/2019 3100-topic6

    39/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 2

    53: 5ondition 5oHerage 5riterion

    if 3# and 3 then

      4#;

    else

      4;

    if 3# then

      if 3 then

      4#;

    else

      4;

    endif

    else

      4;

    endif 

    5 : 5ondition 5oHerage 5riterion

  • 8/17/2019 3100-topic6

    40/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 0

    53: 5ondition 5oHerage 5riterion

    C1 C' C2

    T T T

    T T G

    T G T

    T G G

    G T T

    G T G

    G G T

    G G G

    if 3# and 3

     and 3

    1 then

      4#;

    else

      4;

    if 3# then

      if 3 then

      if 31 then

      4#; 222

      else

      4; 222

      endif

      else

      4; 222

      endif

    else

      4; 222

    5 : 5ondition 5oHerage 5riterion

  • 8/17/2019 3100-topic6

    41/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 1

    53: 5ondition 5oHerage 5riterion

    ♦!ote: C1 an( C' can sti fai for significant test cases

    if & ≠ ! then

    y := 5;

    else

    ' := ' " &;

    endif;

    if ' # then

    ' := ' $ &;

    else

    ' := !;

    endif;

     F  test 2: 67',

  • 8/17/2019 3100-topic6

    42/72

     © Chinese University, CSE Dept. Software Engineering / 6 - '

    5: 0ath 5oHerage 5riterion

    ♦ Seect a test set T sch that a paths ea(ing fro" the initia to the

    fina no(e of >Hs contro fow graph are traverse( at east oncei. Fn genera, the n")er of possi)e e9ection paths in a

    progra" is ################ 

    e.g., 10 si"pe if state"ents *with si"pe con(itions+ IR #####pathsW

    >ro)e": The of paths can )e very arge.

    ii. ?ain co"pe9ity: progra" constrcts which "aBe pathsapproaching infinite IR ########################## 

    iii. a practica sotion: ooB for con(itions that e9ecte oops

    a+ ################## ti"es

    )+ a ######## n")er of ti"esc+ an ####### n")er of ti"es

    5: 0ath 5oHerage 5riterion

  • 8/17/2019 3100-topic6

    43/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 2

    5: 0ath 5oHerage 5riterion

    F"portant points a)ot testing♦Even for C0, co( we enforce the testing

    poicy that 7100 of state"ent coverage "st

    )e achieve(85

     ___________________________________________________________________________________________ 

    5: 0ath 5oHerage 5riterion

  • 8/17/2019 3100-topic6

    44/72

     © Chinese University, CSE Dept. Software Engineering / 6 -

    5: 0ath 5oHerage 5riterion

    ♦%ow a)ot 7100 of reacha)e state"ents )eingcovere(58

    ⇒ Ft is sti very (iffict )ecase har( to enforce

    certain con(itions

    e.g. rea(*9+< :I ' × 9<

    if I then S1<

    ♦ Ft is not (eci(a)e whether sita)e inpt (ata e9ist

    that garantee the e9ection of a state"ent

    *##################### pro)e"+

    Ither 5oHerage 5riteria

  • 8/17/2019 3100-topic6

    45/72

     © Chinese University, CSE Dept. Software Engineering / 6 -

    Ither 5oHerage 5riteria

    ♦Data Gow Coverage Testing Criteria♦Def-Use: ############# pair coverage

    ♦ Fnc(ing C-Use *############# Use+ an( >-Use

    *############# Use+

    a: inte6er;

    a := 7; 2222222

    8

    if (a !) then 2222222

    b := a + #!; 2222222

    5ommission Hs Imission Errors

  • 8/17/2019 3100-topic6

    46/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 6

    5ommission Hs Imission Errors

    ♦Co""ission error: (oing so"ething ####### ♦;"ission error: faiing to (o the ###### thing

    Co""ission errors ;"ission errors7wrong8 or 7e9tra8 7"issing8

    7fase positive8 7fase negative8

    Blac$)Bo' Testing

  • 8/17/2019 3100-topic6

    47/72

     © Chinese University, CSE Dept. Software Engineering / 6 - A

    Blac$ Bo' Testing

    ♦fnctiona testing♦specification-)ase(

    ♦rigor an( for"aity

     3precise operating con(itions IR precise inptcategories

     3 precise e9pecte( rests IR precise co"parisons

    *##################+

    ♦for"a specs encorage ato"atic generationof test sets

    Blac$)Bo' Testing

  • 8/17/2019 3100-topic6

    48/72

     © Chinese University, CSE Dept. Software Engineering / 6 -

    Blac$ Bo' Testing

    ♦ Two e9a"pes *practica approaches+1+ Decision ta)e-)ase( testing

    =  4 spec is (escri)e( )y a (ecision ta)e

    ⇒ provi(es a ############ of inpt an( e9pecte( otpt

    '+ Case-effect graphs= Strctring co"pe9 inpt-otpt specs

    ⇒ a specia case for ######################## 

    %ecision Ta(le)Based Testing

  • 8/17/2019 3100-topic6

    49/72

     © Chinese University, CSE Dept. Software Engineering / 6 -

    %ecision Ta(le Based Testing

    ♦To generate test cases on the )asis of the (ecisionta)e

     3 Usef in ######################## appications

    ♦ E9a"pe 6.

    Consi(er the foowing infor"a specification for a wor( processor:

    The wor( processor "ay present portions of te9t in three (ifferent

    for"ats: pain te9t *p+, )o(face *)+, an( itaics *i+. The foowing

    co""an(s "ay )e appie( to each portion of te9t: "aBe te9t pain *>+,

    "aBe )o(face *+, "aBe itaic *F+, e"phasie *E+, spere"phasie

    *SE+. Co""an(s are avaia)e to (yna"icay set E to "ean either or

    F. *Je (enote sch co""an(s as E I an( E I F, respectivey.+Si"iary, SE can )e (yna"icay set to "ean either *co""an( SE I

    +, or F *co""an( SE I F+, or an( F *co""an( SE I XF+.

    %ecision Ta(le)Based Testing

  • 8/17/2019 3100-topic6

    50/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 0

    %ecision Ta(le Based Testing

    0 true

    B   true true

    !   true true

    E   true true

    SE   true true true

    E,B   true

    E,!   true

    SE,B   true

    SE,!   true

    SE,BM!   true

    Action  ( i ( i ( i (4i (4i

    Ta)e 6.1 Decision ta)e specifying the wor(processor of E9a"pe 6.

     ____________ 

     __________ 

    !")er of co"ns can go p

    to 'n, where n is the n")er of

    inpt con(itions

    To re(ce the of test cases,we se ###########technie

     ______________ 

    The 5ause)Effect Grah

  • 8/17/2019 3100-topic6

    51/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 1

    ♦The case-effect graph technie 3 4 for"a way of strctring co"pe9 inpt-otpt

    specifications

     3 Transfor" the spec of inpts an( otpts into

    ooean vaes 3 The progra" is transfor"e( into a ooean fnction

    E'amle P+P

     F  5auses: 6B4!404E4SE4E,B4E,!4SE,B4SE,!4SE,BM!=

     F  Boolean 6f4f4f4t4f4t4f4f4f4f= ,* E,B and E 

     F  Effects: 6(4i4= e+g+4 7t4f4f* ,* (old te't 

    The 5ause)Effect Grah

  • 8/17/2019 3100-topic6

    52/72

     © Chinese University, CSE Dept. Software Engineering / 6 - '

    ;@

    4!D

    4!D

    ;@

    U

    F

    >

    E

    EIU

    SE

    EIF

    SEIU

    SEIF

    SEIUXF

    )

    i

    p

    Gigre 6.2 >artia and or  graph for a

    wor( processor for )o(-face otpt

    The 5ause)Effect Grah

  • 8/17/2019 3100-topic6

    53/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 2

    ♦ Constraints

    1. e: at "ost one

    2. i : at east one

    3. o: one an( ony one

    4. r : i"pies

    5. m: "asBs

    Gigre 6. Oraphica representation of

    constraints a"ong ogica varia)es

    The 5ause)Effect Grah

  • 8/17/2019 3100-topic6

    54/72

     © Chinese University, CSE Dept. Software Engineering / 6 -

    ;@

    4!D

    4!D

    ;@

    U

    F

    >

    E

    EIU

    SE

    EIF

    SEIU

    SEIF

    SEIUXF

    )

    i

    p

    ""

    "

    "

    Gigre 6. The frag"ent of Gigre 6.2

    ag"ente( with (iagra" showingconstraints a"ong the varia)es

    The 5ause)Effect Grah

  • 8/17/2019 3100-topic6

    55/72

     © Chinese University, CSE Dept. Software Engineering / 6 -

    1. Constraints re(ce the n")er of vai( inpt an( otpt

    cases

    '. Gor each a("issi)e co")ination of otpt vaes, se

    heristics to seect the co")ination of inpt vaes

    *appro9i"ate the ############################+

    a+ for ;@ whose otpt is tre, seect those with ony

    one tre inpt

    )+ for 4!D whose otpt is fase, seect those with ony

    one fase inpt

    Boundary 5onditions

  • 8/17/2019 3100-topic6

    56/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 6

    y

    ♦Typica progra" errors happen at the )on(ary)etween (ifferent cassese.g.,

    if 9 R y then

    S1<

    ese

    S'<

    en(if<

    Seect test cases for 9 R y

      9 Q y an( 9 I y *if 7###8 )eco"es 7###7+

    ♦ Fnitia con(itions

    Testing in the Qarge

  • 8/17/2019 3100-topic6

    57/72

     © Chinese University, CSE Dept. Software Engineering / 6 - A

    g g

    ♦The co")inatoria e9posion of the testingtechnies in the previos sections "aBe

    the" appica)e ony to s"a progra"s

    ♦To (ea with co"pe9 s/w, we nee( other

    technies

    Testing and #odularity

  • 8/17/2019 3100-topic6

    58/72

     © Chinese University, CSE Dept. Software Engineering / 6 -

    ♦;rganie the testing activity to refect the(esign activity: test "o(es separatey, one

    )y one, an( eventay test the whoe syste"

    ♦Strctre the testing into separate phasesmodule testing -unit testing.→ integration testing

    -deHeloment enHironment.

    → system testing 

    -deliHery enHironment.oerational enHironment 

    #odule Testing in 5onte't

  • 8/17/2019 3100-topic6

    59/72

     © Chinese University, CSE Dept. Software Engineering / 6 -

    ♦ Test in the s"a♦ To test a singe "o(e, a co"pete e9ectionenviron"ent is reire(:

    1+ The "o(e "ay se an e9terna operation *e9ternaproce(re ca+

    '+ Ft "ay access non-oca (ata strctres

    2+ Ft "ay )e se( )y another "o(e

    ♦ if *1+ is "issing, )i( ############ 

    *'+ is "issing, constrct te"porary ##########(ata strctre

    *2+ is "issing, )i( ############

    #odule Testing in 5onte't

  • 8/17/2019 3100-topic6

    60/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 60

    ♦st)s 3 proce(re that have the sa"e F/;para"eter as the "issing proce(re, )t with

    a highy si"pifie( )ehavior

     3 e.g., a st) for a sorting proce(re 

    ♦(rivers 3 pieces of co(e that set the share((ata appropriatey an( si"ate the se of the

    "o(e )eing teste(

     3 e.g., a (river for a insert#ta)e proce(re 

    A Stu( /or a Sorting 0rocedure

  • 8/17/2019 3100-topic6

    61/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 61

    ♦Decaration of a seence

    type se9uence(ma&2si'e: NATURAL) is

    record 

    si'e :INTEGER  range !00ma&2si'e := !;

    contents = array(#00ma&2si'e) of INTEGER;

    end; 

    A Stu( for a Sorting 0rocedure

  • 8/17/2019 3100-topic6

    62/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 6'

    The stu( loo$s li$e this:

      procedure sort(se9 :in out se9uence) is

     begin

      rite(the se9uence to be sorted is the folloin6:*);

      for i in #00se90si'e loop

    rite(se90contents(i));

      endloop;  rite(enter the result of sortin6 the se9uence*);

      for in #00se90si'e loop

    read(se90contents(i));

      endloop;

      --- a safer version of the stub could verify the

    --- consistency of the user-supplied data with respect

    --- to procedure specification

    end  sort; 

    A Stu( for a Sorting 0rocedure

  • 8/17/2019 3100-topic6

    63/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 62

    ♦ e+g+

    for i in 2++-seq+ siOe F2 . loo

    if seq+contents -i. *, sq+contents -iM2. then

    write->wrong results?.

    e'it

    endif

    endloo

    A %riHer for an insert_table 0rocedure

  • 8/17/2019 3100-topic6

    64/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 6

    init2table;

    input(el#);

    insert2table(el#);

    --- check whether insertion was done properly

    print2table;

    input(el);

    insert2table(el);

    --- check whether insertion was done properly

    print2table;

    0

    00 

    e.g., Drivers in nit test for yor proect

    A %riHer for an insert_table 0rocedure

  • 8/17/2019 3100-topic6

    65/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 6

    %riHers test ________ or __________ ,* -temorary. suort sKw

    Stu(s

    Gigre 6.6 4 proce(re n(er test, with a st)provi(ing a fnctiona a)straction an( a (river

    STB %R!VER  0RI5E%RE

    N%ER TEST

    5AQQ 5AQQ

    A55ESS TI NINQI5AQ VAR!ABQES

    !ntegration: Bottom) or To)%own

  • 8/17/2019 3100-topic6

    66/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 66

    1+  ############: separatey test a the owest eve "o(es

    *eaves+ in the USES an( FS#C;?>;SED#;G reations, thenthe whoe syste" at once

    '+  #################: gra(ay a(( "o(es into the

    integration testing

    1+  ############: starting aggregation an( testing fro" theeaves of USES hierarchy *reire (rivers+

    '+  ############: starting fro" top-eve "o(es an( sing

    st)s to si"ate ower eve ones

    2+ )oth approaches co( )e se( )y foowing the USES an(

    the FS#C;?>;SED#;G reations

    !ntegration: Bottom) or To)%own

  • 8/17/2019 3100-topic6

    67/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 6A

    ♦ otto" p: ________________________________ 

    ♦ Top (own:  ________________________________ 

    ?1

    ?'

    ?',1

      ?','

    Gigre 6.A 4 OD! strctre showing that ?1 USES

    ?' an( ?' FS#C;?>;SED#;GP?',1, ?',' 

    SES SES

    /our %ifferent !ntegration 0atterns

  • 8/17/2019 3100-topic6

    68/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 6

    To)down integration Bottom)u integration

    /our %ifferent !ntegration 0atterns

  • 8/17/2019 3100-topic6

    69/72

     © Chinese University, CSE Dept. Software Engineering / 6 - 6

    Each (uild reresents one ma;or

    feature or function

    Sandwich integration Build integration

    Searate Testing 5oncerns

  • 8/17/2019 3100-topic6

    70/72

     © Chinese University, CSE Dept. Software Engineering / 6 - A0

    ♦Different types of testing

     3 fnctiona testing

     3 perfor"ance testing

     3 overoa( testing *test the syste" )ehavior (ring

    peaB con(ition+ 3 ro)stness testing *try to )reaB the s/w+

     3 regression testing *verify possi)e regressions of

    s/w )y repeate( testing to avoi( (egra(ation of s/w

    aity+

    A Note on Regression Testing

  • 8/17/2019 3100-topic6

    71/72

     © Chinese University, CSE Dept. Software Engineering / 6 - A1

    ♦@egression Testing: Testing with the prpose ofverifying possi)e ############## of software (ringits ife 3 i.e., (egra(ations of correctness or otheraities (e to ater "o(ifications.

    ♦  ' :, c M 2 roc-O.

     roc-O. redesign c :, c M

    c :, ' M 3 ⇒ ' :,

    ' :,

    ♦&ey: >ropery (esigning an( (oc"enting test casesto "aBe the" ################# .

    5oncluding Remar$s

  • 8/17/2019 3100-topic6

    72/72

     © Chinese University, CSE Dept. Software Engineering / 6 - A'

    ♦Ooas an( reire"ents of verification

    ♦Testing sche"es 3 Testing in the s"a

    = Jhite-)o9 testing

    = acB-)o9 testing 3 Testing in the arge

    = ?o(e testing

    = Fntegration

    ♦Separation of concerns in testing