27.07.2013 Views

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

192 <strong>Testing</strong> Systems with Complex State<br />

On-the-fly testing with a programmable strategy is the testing technique supported<br />

by the ct tool. Internally, it even handles offline testing (as demonstrated in<br />

Chapter 8) as a special case of this.<br />

12.1 On-the-fly testing<br />

First let us demonstrate on-the-fly testing with the client/server example from previous<br />

chapters. On-the-fly testing is the easiest way to begin testing with the ct<br />

(Conformance Tester) tool. It is not necessary to generate a test suite or create a<br />

scenario. All you need is an implementation (Chapter 2), a model program (Chapter<br />

5), and a test harness or stepper (Chapter 8). The built-in strategy of the ct tool<br />

is random testing: in each state, select an enabled action at random. (The strategy is<br />

not completely random; it uses the model program to rule out actions that are not<br />

enabled in the current state.) <strong>We</strong> know that this model program will always reach a<br />

deadlock state or an accepting state, so we don’t have to make any arrangements to<br />

stop the test runs. Let’s see if random testing can reveal the defect we know is there.<br />

<strong>We</strong> issue this command:<br />

ct /r:ClientServer.dll ClientServer.Factory.Create<br />

/r:Stepper.dll /iut:ClientServerImpl.Stepper.Create<br />

/runs:1<br />

One test run executes:<br />

TestResult(0, Verdict("Failure"),<br />

"Run stopped in a non-accepting state",<br />

Trace(<br />

ClientSocket(),<br />

ServerSocket(),<br />

ServerClose()<br />

)<br />

)<br />

The tester randomly chose one of the many paths to a deadlock state (state 9 in<br />

Figure 7.2 in Chapter 7). This happens again and again, so we give ct some guidance<br />

by providing a scenario machine (Figure 7.14 in Chapter 7).<br />

ct /r:ClientServer.dll ClientServer.Factory.Create<br />

/r:Stepper.dll /iut:ClientServerImpl.Stepper.Create<br />

/runs:1<br />

/fsm:Scenario.txt<br />

more free ebooks download links at:<br />

http://www.ebook-x.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!