Model Based Testing Using FSM
Model Based Software Testing Using Finite State
Machine(FSM)
By - Kumaresh Chandra Baruri
Presentation Outlines
 Background Of MBT In Project
 Comparison Between Manual & MBT Process
 Model Based Testing Overview
 How To Derive Test Cases From Model?
 Benefits of MBT
 Obstacles of MBT
 Conclusion
Background Of Using MBT In Project
The following problems raised -
 Difficult to manage test case changes.
 Absence of formatted test cases.
 New test case found while execution.
 Collaboration within team members when got changed.
 % of post delivery defects raised.
Background Of Using MBT In Project
“Traceability between the test
cases generated and the requirements”
Comparison Between Manual & MBT Process
SW Functional
Specification
Independently
Testable Items
Generate Test Cases
Review and Modify Test
Cases
Finalized Test Cases
To Conduct Test
Can we trust
the test items
selected?
Usingi/o
Comparison Between Manual & MBT Process(cont…)
Comparison Between Manual & MBT Process(cont…)
0
10
20
30
40
50
60
70
80
Reminder Graph Scrolling
Manual
MBT
Real example from two features of OHI-Connected Wellness :
Model Based Testing Overview
Model Based Testing(MBT) refers to
Black Box Testing process Derivation of test cases from model.
Functional Aspects Oriented. Executing Test Cases.
Prediction of system’s behaviour Verification of Test Results
is a partial description of
Model System
Test Specification Test Cases
can be run against
are abstract versions of
can be derived from
How To Derive Test Cases From Model?
System Converted to Model
How To Derive Test Cases From Model(cont…)?
How to generate test case from model?
How To Derive Test Cases From Model(cont…)?
FSM provides solution that refers to-
Event Action  Change State
How To Derive Test Cases From Model(cont…)?
One transition from State A to State B
A B
Transition
Current State Next State
FSM operates by traversing from state to state.
Every Transition contains an Input Event and Next State
A Transition can also define OUTPUTS and ACTIONS
From FSM, test spec can be generated.
From test spec, Test Case will be created.
I/O
How To Derive Test Cases From Model(cont…)?
Using
FSM
How To Derive Test Cases From Model(cont…)?
Standard
Scientific
Simple But
Difficult to
Test
hmm … let’s see …
I Start the calculator, and the calculator starts running
- OK.
I select Scientific, and the calculator goes to Scientific mode.
- Good.
I Enter a Number, and the number appears in the display
– Yup.
I select Standard, and the calculator goes back to Standard mode
- OK.
…
Start
Scientific
Enter a Number
Standard
…
Exploratory Testing To Calculator
How To Derive Test Cases From Model(cont…)?
Step Action Result
1 Start Calculator should be Running
2 Scientific Calculator in Scientific mode
3 Enter Number Number in the display
4 Standard Calculator in Standard mode
…
How do you think
to try these actions
in this order?
And how do you know
you’d end up with
these results?
Scripting The Calculator Testing
How To Derive Test Cases From Model(cont…)?
How To Derive Test Cases From Model(cont…)?
NotRunning
Start
Scientific
Enter Number
Standard
?
You have a model in
Your Head
You Could Hand-Draw Your Model
But you wouldn’t
want to do it.
How To Derive Test Cases From Model(cont…)?
1 Start
2 Scientific
3 Enter Number
4 Standard
5 …
You Could Hand-Trace Test Sequences
But you wouldn’t
want to do this
either.
How To Derive Test Cases From Model(cont…)?
!
Let the Machine Do It
How To Derive Test Cases From Model(cont…)?
But First…
Let’s talk about
calculator behavior
How To Derive Test Cases From Model(cont…)?
Standard
Scientific
Start Simply
How To Derive Test Cases From Model(cont…)?
Get a Bit More Complex
How To Derive Test Cases From Model(cont…)?
And Even More Complex
How To Derive Test Cases From Model(cont…)?
What Does This Model Care About?
How To Derive Test Cases From Model(cont…)?
Application status:
• Running
• Not Running
Mode status:
• Standard
• Scientific
Display status:
•Empty
•Not Empty
This Model
Cares About
1 Start
2 Scientific
3 Stop
4 Start
5 Standard
6 Stop
7 Clear
8 Stop
9 Start
10 Scientific
11 Clear
12 Enter Number
13 …..
Let The Machine Do It For You
Two possible ways to
derive TCs-
1.Covering all the states
2.Covering both states
and transitions
How To Derive Test Cases From Model(cont…)?
Beeline
Beeline
 Choose any 2 nodes in the path
 Find the shortest path between them
 Execute the spliced ‘shortcut’ path
 Evaluate the results and repeat
How To Derive Test Cases From Model(cont…)?
So let’s generate a few thousand tests
…
Possible Test Specs
1. TS1: 1, 2
2. TS2: 1,2,3
3. TS3: 3,5
4. TS4: 5,3
….. ….. …..
How To Derive Test Cases From Model(cont…)?
Let’s Generate
Test Spec
Beeline
Benefits of MBT
 Easy test case maintenance
 Reduced costs/more tests
 Can run different tests on 1000s of machines
 Early bug detection
 Increased bug count
 Time savings
 Time to address bigger test issues
 Improved tester job satisfaction
Beeline
Obstacles of MBT
 Comfort factor
 This is not your parents’ test automation
 Skill sets
 Need testers who can design
 Expectations
 Models can be a significant upfront investment
 Will never catch all the bugs
 Metrics
 Bad metrics: bug counts, number of test cases
 Better metrics: spec coverage, code coverage
Conclusion
Context Manual Model Based
Build Model - 10 days
Typ. Change 5 Days 15 min
Test Case Gen 20 min/test 3 sec/test
Test Case Exec 3-10 min/test 2 min/test
Report Gen 3 min/test 0*
Process Matrix Comparison Result

Model based testing using finite state machine(FSM)

  • 1.
    Model Based TestingUsing FSM Model Based Software Testing Using Finite State Machine(FSM) By - Kumaresh Chandra Baruri
  • 2.
    Presentation Outlines  BackgroundOf MBT In Project  Comparison Between Manual & MBT Process  Model Based Testing Overview  How To Derive Test Cases From Model?  Benefits of MBT  Obstacles of MBT  Conclusion
  • 3.
    Background Of UsingMBT In Project The following problems raised -  Difficult to manage test case changes.  Absence of formatted test cases.  New test case found while execution.  Collaboration within team members when got changed.  % of post delivery defects raised.
  • 4.
    Background Of UsingMBT In Project “Traceability between the test cases generated and the requirements”
  • 5.
    Comparison Between Manual& MBT Process SW Functional Specification Independently Testable Items Generate Test Cases Review and Modify Test Cases Finalized Test Cases To Conduct Test Can we trust the test items selected? Usingi/o
  • 6.
    Comparison Between Manual& MBT Process(cont…)
  • 7.
    Comparison Between Manual& MBT Process(cont…) 0 10 20 30 40 50 60 70 80 Reminder Graph Scrolling Manual MBT Real example from two features of OHI-Connected Wellness :
  • 8.
    Model Based TestingOverview Model Based Testing(MBT) refers to Black Box Testing process Derivation of test cases from model. Functional Aspects Oriented. Executing Test Cases. Prediction of system’s behaviour Verification of Test Results is a partial description of Model System Test Specification Test Cases can be run against are abstract versions of can be derived from
  • 9.
    How To DeriveTest Cases From Model? System Converted to Model
  • 10.
    How To DeriveTest Cases From Model(cont…)? How to generate test case from model?
  • 11.
    How To DeriveTest Cases From Model(cont…)? FSM provides solution that refers to- Event Action  Change State
  • 12.
    How To DeriveTest Cases From Model(cont…)? One transition from State A to State B A B Transition Current State Next State FSM operates by traversing from state to state. Every Transition contains an Input Event and Next State A Transition can also define OUTPUTS and ACTIONS From FSM, test spec can be generated. From test spec, Test Case will be created. I/O
  • 13.
    How To DeriveTest Cases From Model(cont…)? Using FSM
  • 14.
    How To DeriveTest Cases From Model(cont…)? Standard Scientific Simple But Difficult to Test
  • 15.
    hmm … let’ssee … I Start the calculator, and the calculator starts running - OK. I select Scientific, and the calculator goes to Scientific mode. - Good. I Enter a Number, and the number appears in the display – Yup. I select Standard, and the calculator goes back to Standard mode - OK. … Start Scientific Enter a Number Standard … Exploratory Testing To Calculator How To Derive Test Cases From Model(cont…)?
  • 16.
    Step Action Result 1Start Calculator should be Running 2 Scientific Calculator in Scientific mode 3 Enter Number Number in the display 4 Standard Calculator in Standard mode … How do you think to try these actions in this order? And how do you know you’d end up with these results? Scripting The Calculator Testing How To Derive Test Cases From Model(cont…)?
  • 17.
    How To DeriveTest Cases From Model(cont…)? NotRunning Start Scientific Enter Number Standard ? You have a model in Your Head
  • 18.
    You Could Hand-DrawYour Model But you wouldn’t want to do it. How To Derive Test Cases From Model(cont…)?
  • 19.
    1 Start 2 Scientific 3Enter Number 4 Standard 5 … You Could Hand-Trace Test Sequences But you wouldn’t want to do this either. How To Derive Test Cases From Model(cont…)?
  • 20.
    ! Let the MachineDo It How To Derive Test Cases From Model(cont…)?
  • 21.
    But First… Let’s talkabout calculator behavior How To Derive Test Cases From Model(cont…)? Standard Scientific
  • 22.
    Start Simply How ToDerive Test Cases From Model(cont…)?
  • 23.
    Get a BitMore Complex How To Derive Test Cases From Model(cont…)?
  • 24.
    And Even MoreComplex How To Derive Test Cases From Model(cont…)?
  • 25.
    What Does ThisModel Care About? How To Derive Test Cases From Model(cont…)? Application status: • Running • Not Running Mode status: • Standard • Scientific Display status: •Empty •Not Empty This Model Cares About
  • 26.
    1 Start 2 Scientific 3Stop 4 Start 5 Standard 6 Stop 7 Clear 8 Stop 9 Start 10 Scientific 11 Clear 12 Enter Number 13 ….. Let The Machine Do It For You Two possible ways to derive TCs- 1.Covering all the states 2.Covering both states and transitions How To Derive Test Cases From Model(cont…)?
  • 27.
    Beeline Beeline  Choose any2 nodes in the path  Find the shortest path between them  Execute the spliced ‘shortcut’ path  Evaluate the results and repeat How To Derive Test Cases From Model(cont…)?
  • 28.
    So let’s generatea few thousand tests … Possible Test Specs 1. TS1: 1, 2 2. TS2: 1,2,3 3. TS3: 3,5 4. TS4: 5,3 ….. ….. ….. How To Derive Test Cases From Model(cont…)? Let’s Generate Test Spec
  • 29.
    Beeline Benefits of MBT Easy test case maintenance  Reduced costs/more tests  Can run different tests on 1000s of machines  Early bug detection  Increased bug count  Time savings  Time to address bigger test issues  Improved tester job satisfaction
  • 30.
    Beeline Obstacles of MBT Comfort factor  This is not your parents’ test automation  Skill sets  Need testers who can design  Expectations  Models can be a significant upfront investment  Will never catch all the bugs  Metrics  Bad metrics: bug counts, number of test cases  Better metrics: spec coverage, code coverage
  • 31.
    Conclusion Context Manual ModelBased Build Model - 10 days Typ. Change 5 Days 15 min Test Case Gen 20 min/test 3 sec/test Test Case Exec 3-10 min/test 2 min/test Report Gen 3 min/test 0* Process Matrix Comparison Result