|
|
YOUR FEEDBACK
|
TOP MICROSOFT .NET LINKS Tools
Using Spec Explorer for Model-Based Test Development
Use Spec Explorer to improve quality assurance
By: Su Llewellyn
Dec. 29, 2005 06:15 PM
Digg This!
Page 2 of 2
« previous page
Finite State Machines (FSM) A finite state machine is really one instance of your model space. Spec Explorer can generate new and different finite state machines. You just have to give it a new random seed under Exploration Settings on the Explore menu. The FSM will be different with a new random seed if it were limited somehow - for example, if you limited the finite state machine by using state grouping or limits on the number of transitions or states to explore. If the FSM is complete, that is, without limits, then it will represent all of the states and transitions so that the RandomSeed value won't matter. Spec Explorer automatically generates a view of your model when you choose Run from the Explore Menu (see Figure 2). The Channel example has two views: Full and Grouped. You can create as many views as you want of your model. You'll find that the grouping feature is not only handy but becomes necessary as your state space starts to grow bigger. You would group by some model expression that is important in the context of your model. The Channel sample is grouped by OrderExpression and the expression looks like this: Figure 3 provides the same grouped view by itself for ease of reading. Spec Explorer allows you to save off the graphical views of your model. I often include these in my own test specs when I'm developing models and save them as JPGs. They are handy for reference.
Generating Test Suites That means in your class library you should have a publicly accessible method of a class with the same function signature. If you choose Test Settings from the Test menu, you bring up a page and choose the Test Bindings tab (see Figure 4). If you click the Autofill Scope button, you can drill down into your class library's namespace and choose the class name. Spec Explorer will automatically bind your class methods to your model actions. Once the test bindings are in place, you may generate test suites to your heart's content. The Run command on the Test menu will actually run your automation. If you need to export your test automation so that it may be run from the command line, I have written a few simple procedures below. To Generate a Test Suite
I don't want to finish this article without saying something about on-the-fly testing. The real power behind model-based testing lies in allowing the model automation to run and explore the space. If you choose Start On the Fly Testing from the Tools menu, Spec Explorer will run your model automation and hopefully you'll be filing new bugs in no time. It's not about creating test cases for their own sake, it's about finding bugs - so let the model automation find the bugs for you. On-the-fly testing is powerful when: 1) the model space is huge, 2) many transitions are unlikely, or 3) the system is asynchronous. On-the-fly testing is not guaranteed to explore all possible paths, but it is good at quickly exploring common ones. Since number 1 is obvious, let's consider the second case: many transitions are unlikely. Suppose you have a function bool Foo() that writes to a file and returns success or failure. It may return false if the hard drive is out of space. Full FSM generation will explore both cases, but in reality you may never see a failure because most hard drives are large. On-the-fly testing won't waste time analyzing the path where Foo failed if the hard drive never runs out of space at run time. Now consider possibility 3: the system is asynchronous. Suppose your implementation has multiple threads, and when you call Foo() it causes two observable events, Observable1() and Observable2(), to happen asynchronously. Full FSM generation will explore both orderings (Observable1 then Observable2, and vice versa), but in reality the NT thread scheduler may cause (1 then 2) 99 percent of the time. On-the-fly testing won't waste the time analyzing the (2 then 1) path 99 percent of the time, because it doesn't happen at run time.
Conclusion Page 2 of 2 « previous page
MICROSOFT .NET LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
|||||||||||||||||||||||||||||||||||