0% found this document useful (0 votes)
21 views19 pages

06 - State Transition Testing

Uploaded by

Hân Lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views19 pages

06 - State Transition Testing

Uploaded by

Hân Lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Software Testing

Decision Table Testing

Tran Duy Hoang


State Transition Testing

• Helpful to test different system transitions


• General approach
• Describe the System Under Test as a “finite state machine” or “state
transition diagram”
• Derive test cases based on State Transition Coverage
• Create State Table based on the diagram to evaluate Invalid
Transitions

Department of Software Engineering 2


State Transition Diagram

Department of Software Engineering 3


State Diagram for Login

Ref: https://www.guru99.com/state-transition-testing.html

Department of Software Engineering 4


State Transition Table

Correct PIN Incorrect PIN


S1. Start _ _
S2. 1st Try S5 S2
S3. 2nd Try S5 S4
S4. 3rd Try S5 S6
S5. Access Granted _ _
S6. Account Blocked _ _

Department of Software Engineering 5


State Transition Coverage

• State Transition Coverage % = Number of identified states or


transitions tested / The total number of states or transitions in the
test object.
• è All States Coverage
• è All Transitions Coverage

Department of Software Engineering 6


State Transition Coverage

Ref: https://www.guru99.com/state-transition-testing.html

Department of Software Engineering 7


State Diagram for TV

Department of Software Engineering 8


N-Switch Testing

• N-switch tests are state transition tests in which the test cases are
designed to execute all valid sequences of N+1 transitions.
• è 0-switch: every single (0+1=1) transition is tested
• è 1-switch: all combinations of two (1+1=2) consecutive
transitions are tested transitions are tested

Department of Software Engineering 9


0-switch Coverage Test cases

Department of Software Engineering 10


Quizzes

Ref: https://www.testing.vn/state-transition/
Department of Software Engineering 11
Quizzes

Department of Software Engineering 12


Quizzes

Department of Software Engineering 13


State Diagram for a Bank Account

Department of Software Engineering


State Transition Table

• List all possible state-transition combinations, not just the valid


ones
• Advantage: Help detect defects in implementation that enable invalid paths
from one state to another
• Disadvantage: state tables become very large very quickly as the number
of states and events increases

Department of Software Engineering


State Table for Bank Account

Department of Software Engineering


Test Cases from State Table

#TC Precondition Condition Expected Result (Action) Note


(State) (Event)
TC1 No account Open account Account created with balance >=0 S1 => S2
TC2 No account Withdraw Message: Account does not exist S1 => S3
TC3 No account Close account Message: Account does not exist S1 => S4
TC4 Account with Deposit D Balance = balance + D S2 => S2
balance >= 0
TC5 Account with Withdraw Balance = balance – W >= 0 S2 => S2
balance >= 0 W<=balance

Department of Software Engineering 17


Test Cases from State Table

#TC Precondition Condition (Event) Expected Result (Action) Note


(State)
TC6 Balance >=0 Withdraw W>balance Balance = (balance – W ) < 0 S2 => S3
TC7 Balance >=0 Close account Account closed S2 => S4
Balance = 0
TC8 Balance < 0 Deposit D+Balance>=0 Balance = Balance + D >= 0 S3 => S2
TC9 Balance < 0 Deposit D+Balance<0 Balance = Balance + D < 0 S3 => S3
TC10 Balance < 0 Write bad debit Account in bad debit S3 => S4

Department of Software Engineering 18


Test Cases from State Table

#TC Precondition (State) Condition (Event) Expected Result (Action) Note


TC11 Account in bad debit Deposit D+Balance>=0 Balance = Balance + D >= 0 S4 => S2
TC12 Account in bad debit Deposit D+Balance<0 Balance = Balance + D < 0 S4 => S3
TC13 Account closed Deposit Message: Account already closed S4 => S2
TC14 Account in bad debit Withdraw Message: Account in bad debit S4 => S3
TC15 Account closed Withdraw Message: Account already closed S4 => S3
TC16 Account in bad debit Close Message: Account in bad debit S4 => S4
TC17 Account closed Close Message: Account already closed S4 => S4

Department of Software Engineering 19

You might also like