440 likes | 625 Views
2. What are we going to talk about?. Model-based testing technique:Using The Visual Test
E N D
1. Finite State Model-Based Testing on a Shoestring
2. 2 What are we going to talk about? Model-based testing technique:
Using The Visual Test® tool (Rational Software ®) we will :
1. Create a finite state model of an application.
2. Generate sequences of tests actions from the model.
3. Execute the test actions against the application.
4. Determine if the application worked right.
5. Find bugs.
3. 3 Running Example – the Clock application of Windows NT
4. 4 What is a model?
5. 5 Motivation for using Model-based testing technique
6. 6 Motivation for using Model-based testing technique
7. 7 How can a model be used? Communication
Generate code
Generate test cases
Provide an oracle for test cases
8. 8 More advantages of using model-based testing
9. 9 Sample problem - File system
10. 10 Step One – create a Finite State Model of an Application The Operation modes:
System mode:
NOT_RUNNING means Clock is not running
RUNNING means Clock is running
Setting mode:
ANALOG means Analog display is set
DIGITAL means Digital display is set
11. 11 Step One – create a Finite State Model of an Application
The Actions:
Start the Clock application
Stop the Clock application
Select Analog setting
Select Digital setting
12. 12 Step One – create a Finite State Model of an Application
13. 13 Step One – create a Finite State Model of an Application
14. 14 Step One – create a Finite State Model of an Application
15. 15 Step One – create a Finite State Model of an Application
16. 16 Step One – create a Finite State Model of an Application
17. 17 State Transition Diagram for the clock Model
18. 18 Step Two - Generate sequences of tests actions from the model Testing an application is like following a path through a finite state model.
Different types of traversals can meet different needs of testers.
One of the following strategies can be adopted:
- Execute every possible action.
- Testing combinations of Actions.
- Random Walks.
- Testing the most likely paths.
19. 19 Step Two - Generate sequences of tests actions from the model (Cont.)
- Execute every possible action
20. 20
Graph theory techniques allow us to use the behavioral information stored in models to generate new and useful tests.
Euler cycle - a graph cycle which uses each edge exactly once.
A connected graph has an Eulerian circuit iff it has no vertices of odd degree.
Step Two - Generate sequences of tests actions from the model (Cont.)
21. 21 Step Two - Generate sequences of tests actions from the model
The Chinese Postman Problem:
Given that it is impossible to cross each bridge exactly once and return to the starting point, what is the minimal amount of re-crossing a walker needs to do? (Kwan 1962)
22. 22 Step Two - Generate sequences of tests actions from the model
The Chinese Postman Solution:
“Eulerizing” the graph by duplicating links and performing an Euler tour.
23. 23 Step Two - Generate sequences of tests actions from the model
24. 24 Step Two - Generate sequences of tests actions from the model
25. 25 Step Two - Generate sequences of tests actions from the model
26. 26
Step Two - Generate sequences of tests actions from the model
27. 27 Step Two - Generate sequences of tests actions from the model
28. 28
Create a dual graph of the original graph (i.e., a graph in which the arcs of the original graph are converted to nodes)
Everywhere in the original graph that arc 1 is an incoming to a node and arc 2 is outgoing from the same node, create an arc in the dual graph from node 1 to node 2. For instance, in the left hand graph in Figure 6, arc “a” is incoming to the node from which arc “b” is outgoing; therefore in the dual graph there is an arc from node “a” to node “b”.
Eulerize the dual graph (by duplicating arcs to balance node polarities)
Traverse the Eulerized graph, noting the names of the nodes that you pass. Step Two - Generate sequences of tests actions from the model
29. 29 Step Two - Generate sequences of tests actions from the model Random Walks: From the current node, choose an outgoing link at random, follow that link to the next node and repeat the process.
Advantages:
- Simple to implement.
- Can be very useful.
Disadvantage:
- Could be very inefficient about covering a large graph quickly.
30. 30 Step Two - Generate sequences of tests actions from the model
31. 31 Assign probabilities to the links in the graph (as with regular Markov chains)
Establish a minimum probability for the paths that you are interested in, such as 0.0000001
Starting at the initial node, move through the graph, keeping track of the cumulative probability of the links you’ve traversed so far.
Continue traversing links in the graph until you reach the final node of the graph or until the cumulative probability of the path falls below the minimum you’ve established.
If you have reached the final node, record the path that got you there as well as its probability.
If you have merely fallen below the minimum probability, back up and try a different link.
Once you have collected all the paths in the graph that have cumulative probability greater than your minimum, sort them in order of their cumulative probability, from highest to lowest.
Step Two - Generate sequences of tests actions from the model
32. 32 Chinese Postman tour on our example:
Start
Analog
Digital
Digital
Stop
Start
Analog
Stop
Step Two - Generate sequences of tests actions from the model
33. 33 Step Three - Execute the test actions against the application Take advantage of the functions Visual Test® can offer to interact with the application we are testing:
34. 34 Step Three - Execute the test actions against the application
35. 35
36. 36
37. 37
38. 38 Step Four - Determine if the application worked right.
39. 39 Step Four - Determine if the application worked right.
40. 40 Step Four - Determine if the application worked right.
41. 41 Step Five - Find bugs
42. 42 Step Five - Find bugs
43. 43 What did we learn? Using a running example we implemented the Model-based testing technique which demonstrated the fact that it is an efficient technique for generating test cases based on the application behavior.
We saw different types of tests that can be generated automatically from traversing the model.
Unlike traditional testing this technique enables us to maintain, review and update the test programs more easily.
44. 44 References 1. Finite State Model-Based Testing on a Shoestring
Harry Robinson
2. Graph Theory Techniques in Model-Based Testing
Harry Robinson
3. A methodology and architecture for automated software testing
Gronau, Hartman
http://www.geocities.com/model_based_testing//online_papers.htm