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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Systems with Finite <strong>Model</strong>s 147<br />

When we execute this command, the test fails:<br />

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

"Action ’ClientReceive_Finish(double(\"99\"))’ not enabled in the model",<br />

Unexpected return value of finish action, expected:<br />

ClientReceive_Finish(double "99.9"))<br />

Trace(<br />

Test(0),<br />

ServerSocket(),<br />

ServerBind(),<br />

ServerListen(),<br />

ClientSocket(),<br />

ClientConnect(),<br />

ServerAccept(),<br />

ServerSend(double("100")),<br />

ClientReceive_Start(),<br />

ClientReceive_Finish(double("100")),<br />

ServerSend(double("99.9")),<br />

ClientReceive_Start(),<br />

ClientReceive_Finish(double("99"))<br />

)<br />

)<br />

The output shows the trace of the actual test run through the action that failed<br />

(compare to the trace of the test case in Figure 8.3). The message indicates that this<br />

test failed because the return value 99 in the last finish action is not the same as the<br />

expected return value 99.9 computed by the model program and stored in test case.<br />

8.5 Limitations of offline testing<br />

The five test cases in the first test suite all pass; they do not reveal the defect in<br />

the implementation that we discussed in Chapter 2, Section 2.10. Recall that the<br />

defect causes a failure after the server sends the client more than four characters<br />

(e.g., "100.0"), but the client only fails when it receives the message after the first<br />

message with four characters. At least two messages must be sent and received to<br />

expose the defect (where the first message contains more than four characters). Each<br />

of the test cases in the first test suite only send and receive one message, so they<br />

cannot expose the defect.<br />

The single test case in the second test suite does expose the defect, because<br />

two messages are sent and received, and the first message contains more than four<br />

characters.<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!