unit 7 testing

4
 10/26/2012 1 UNIT 7 STATES,STATE GRAPHS AND TRANSITION TESTING D.ABHISHEKH MS(SE) State Graphs A state is defined as : “ A combination of circumstances or attributes belongin g for the time being to a person or thing.” For example, a moving automobile whose engine is running can have the following states with respect to its transmission. Reverse gear Neutral gear First gear Second gear Third gear Fourth gear State g raph - Example For example, a program that detects the character sequence “ZCZC” can be in the following states. Neither ZCZC nor any part of it has been detected. Z has been detected. ZC has been detected. ZCZ has been detected. ZCZC has been detected. None Z ZC ZCZ ZCZC Z C Z C Z A,C Z,C,A Z A A A,C

Upload: abhi

Post on 03-Nov-2015

217 views

Category:

Documents


0 download

DESCRIPTION

software testing notes

TRANSCRIPT

  • 10/26/2012

    1

    UNIT 7

    STATES,STATE GRAPHS AND

    TRANSITION TESTING

    D.ABHISHEKH MS(SE)

    State Graphs

    A state is defined as : A combination of circumstances or attributes belonging for the time being to a person or thing.

    For example, a moving automobile whose engine is running can have the following states with respect to its transmission.

    Reverse gear

    Neutral gear

    First gear

    Second gear

    Third gear

    Fourth gear

    State graph - Example

    For example, a program that detects the character sequence ZCZC can be in the following states.

    Neither ZCZC nor any part of it has been detected.

    Z has been detected.

    ZC has been detected.

    ZCZ has been detected.

    ZCZC has been detected.

    None Z ZC ZCZ ZCZC

    Z C Z C

    Z

    A,C Z,C,A

    Z

    A

    AA,C

  • 10/26/2012

    2

    STATE OKAY

    ERROR

    1 1/NONE 2/REWRITE

    2 1/NONE 4/REWRITE

    3 1/NONE 2/REWRITE

    4 3/NONE 5/ERASE

    5 1/NONE 6/ERASE

    6 1/NONE 7/OUT

    7

    TRANSITION BUGS

    Example to convert specification into a state graph

    ----------------------------------------------------------------

    With an example, we will now follow a set of rules, i.e. specifications to deduce the state graph and state tables

    RULE 1:

    The program will maintain an error counter which will be incremented

    whenever there is an error.

  • 10/26/2012

    3

    Initial state graph deduced from Rule1

    error error error error . . .

    Okay

    RULE 1: The program will maintain an error counter,

    which will be incremented whenever there is an

    error.

    0 1 2 3 4

    State table from the state graph(refer earlier slide for the

    graph)

    STATE OKAY ERROR

    0 0/None 1/

    1 2/

    2 3/

    3 4/

    4 5/

    5 6/

    6 7/

    7 8/

    INPUT

    Rule 2: If there is an error, rewrite the block

    STATE OKAY ERROR

    0 0/None 1/REWRITE

    1 2/REWRITE

    2 3/REWRITE

    3 4/REWRITE

    4 5/REWRITE

    5 6/REWRITE

    6 7/REWRITE

    7 8/REWRITE

    INPUT

    For all Error entries, we include a Rewrite

    Rule 3: If there have been 3 successive errors, erase of tape and then rewrite the block

    STATE OKAY ERROR

    0 0/None 1/REWRITE

    1 2/REWRITE

    2 3/REWRITE,ERASE,REWRITE

    3 4/REWRITE,ERASE,REWRITE

    4 5/REWRITE,ERASE,REWRITE

    5 6/REWRITE,ERASE,REWRITE

    6 7/REWRITE,ERASE,REWRITE

    7 8/REWRITE,ERASE,REWRITE

    INPUT

    The first 3rd successive error

    occurs

  • 10/26/2012

    4

    STATE OKAY ERROR

    0 0/None 1/REWRITE

    1 2/REWRITE

    2 3/REWRITE,ERASE,REWRI

    TE

    3 4/REWRITE,ERASE,REWRI

    TE

    4 5/REWRITE,ERASE,REWRI

    TE

    5 6/OUT

    6

    7

    Rule 4: If there have been 3 successive erasures, and another error occurs, put the unit out of service

    We have 3 successive erasures- so

    we now put the unit out of service

    Rule 5: If the erasure was successful, return to the

    normal state and clear the error counter

    STATE OKAY ERROR

    0 0/None 1/REWRITE

    1 2/REWRITE

    2 3/REWRITE,ERASE,REWRI

    TE

    3 0/None 4/REWRITE,ERASE,REWRI

    TE

    4 0/None 5/REWRITE,ERASE,REWRI

    TE

    5 0/None 6/OUT

    6

    7

    We reach State 3 after the 1st

    erasure. If successful, we return to

    None & the error counter is made

    0

    Rule 6: If the rewrite was successful, decrement the

    error counter and return to the previous state

    STATE OKAY ERROR

    0 0/None 1/REWRITE

    1 0/None 2/REWRITE

    2 1/None 3/REWRITE,ERASE,REWRI

    TE

    3 0/None

    2/None

    4/REWRITE,ERASE,REWRI

    TE

    4 0/None

    3/None

    5/REWRITE,ERASE,REWRI

    TE

    5 0/None

    4/None

    6/OUT

    6

    7

    INPUT

    Example: Say we are at state 1. The error

    counter here is 2. If we have a

    successful(okay) rewrite, the entry for okay

    at state 2 will have error counter

    decremented by 1 which is:

    (2-1)/None where, None output for success.

    Conclusion

    Observe the previous slide-RULE6 states If the rewrite was successful, then decrement the error counter and return to the previous state. The requirement probably was If there have been no erasures and rewrite was successful, then

    This has now resulted in contradictions which is a concern as it might lead to bugs.

    It is always unlikely that a contradictory specification can result in a satisfactory implementation.