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.

44 <strong>Why</strong> <strong>We</strong> <strong>Need</strong> <strong>Model</strong>-<strong>Based</strong> Analysis<br />

?Timeout, Message, OK<br />

ReportLostMessage<br />

?Command, Timeout, OK<br />

Calibrate ’99.9’<br />

?Timeout, Timeout, OK<br />

Poll<br />

?Message ’99.9’, Message, OK<br />

CheckMessage ’99.9’, compare to 99.9, OK<br />

?Command, Timeout, OK<br />

Calibrate ’99.9’<br />

?Exit, Timeout, OK<br />

Did the expected handlers run? [y/n] y<br />

Tests run: 1, Failures: 0, Not run: 0, Time: 8.606 seconds<br />

These tests confirm that the controller works as intended in these runs. Can we<br />

conclude from this that the controller will always work?<br />

3.4 Failures in simulation<br />

<strong>We</strong> experiment with the simulator and find that the controller does not always behave<br />

as we intend. Recall that we intend that a calibrate command will be carried out if<br />

the most recent sample from the sensor is within-range, but will not be carried out<br />

if the most recent sample is out-of-range. <strong>We</strong> also intend that the controller should<br />

not experience any generic failures such as program crashes (unhandled exceptions<br />

in .NET), deadlocks, or endless cycles that get nowhere. Despite our intentions,<br />

we observe examples of all of these (which we can reproduce by coding unit<br />

tests).<br />

In this run, CommandWhenWaiting, a calibrate command is ignored even though the<br />

sensor is OK. The command arrives when the controller is waiting for a message;<br />

no handler runs.<br />

?Timeout, Timeout, Error<br />

Reset<br />

?Message ’99.9’, Message, Error<br />

CheckMessage ’99.9’, compare to 99.9, OK<br />

?Timeout, Timeout, OK<br />

Poll<br />

?Command, Message, OK<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!