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.

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

Probes typically increase the possibility of finding errors earlier. <strong>We</strong> can see how<br />

ct discovers the bug in the faulty bag implementation much sooner than before,<br />

by using Create<strong>Model</strong>WithProbe composed with ProbeScenario and AddDeleteScenario<br />

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

"Inconsistent views of state: model:Set() iut:Set(\"b\")",<br />

Trace(<br />

Add("b"),<br />

CheckView(Set("b")),<br />

Delete("b"),<br />

CheckView(Set())<br />

)<br />

)<br />

12.5.2 Test execution and termination<br />

The two primary options of ct that directly control the size of a generated test suite<br />

are runs and steps. The value of runs is the desired number of test runs. Each test<br />

run starts from the initial state of the model program. Both the IUT and the strategy<br />

are reset between test runs. Recall that resetting the strategy resets the underlying<br />

model program. This is an outline of the top-level loop:<br />

int k = 0;<br />

while (k < runs)<br />

{<br />

if (!TestResultNotifier(RunTest(k))) return;<br />

strategy.Reset();<br />

stepper.Reset();<br />

k += 1;<br />

}<br />

The test result notifier is a delegate that can be set in the conformance tester. This<br />

delegate controls when the conformance tester should terminate. In ct this delegate<br />

is set to a function that outputs the test result and returns false, if the test run failed<br />

and the continueOnFailure option of ct is turned off, and returns true otherwise.<br />

Each test result is written either to the console or to a log file if one is provided by<br />

the logfile option of ct.<br />

Test execution algorithm. An outline of the algorithm that executes a single<br />

test run is shown in Figure 12.7. Each individual test run starts from the initial<br />

state and attempts to produce a run of at least as many actions as specified by<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!