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 141<br />

TestSuite(<br />

TestCase(<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.9")),<br />

ClientSend(),<br />

ServerReceive(),<br />

ClientClose(),<br />

ServerCloseConnection(),<br />

ServerClose()<br />

)<br />

)<br />

Figure 8.3. Client/server: test suite file contents, showing a trace with terms.<br />

The otg tool saves test suites in text files. Figure 8.3 shows the contents of<br />

ScenarioTest.txt, which describes the test suite with one test case whose FSM<br />

is displayed in Figure 8.2. Each test case in a test suite file is a trace, text that<br />

represents a program run. A trace is not expressed in C# code, although it resembles<br />

code (compare the trace in Figure 8.3 to the unit test in Chapter 2, Figure 2.10,<br />

and also to the trace we wrote in Chapter 5, Section 5.6.1). A trace is a sequence<br />

of actions. Each action is expressed as a term, a data structure that the tools use to<br />

represent actions. The syntax of terms is easy to understand, but differs from the<br />

syntax of C# method calls. The tools use terms because they are easier to work with<br />

than program text. You must work with terms in your test harness code.<br />

Actions are not exactly the same as method calls. Most of the actions in Figure 8.3<br />

correspond to a method call, but not all. Each client Receive method call corresponds<br />

to two actions, for example:<br />

ClientReceive_Start(),<br />

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

The first action, called the start action, is the method call. The second action, the<br />

finish action, is the method return including the expected return value computed 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!