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.

8 <strong>Testing</strong> Closed<br />

Systems<br />

In this chapter we introduce model-based testing. <strong>We</strong> test the client/server implementation<br />

we described in Chapter 2, and reveal the defect we discussed there. <strong>We</strong><br />

generate the test suite and check the results with the model program we developed in<br />

Chapter 5, Section 5.6. <strong>We</strong> introduce our test generator tool otg and our test runner<br />

tool ct, and show how to write a test harness that connects an implementation to the<br />

ct tool.<br />

In this chapter we describe offline test generation, where test suites are generated<br />

before running the tests. Offline test generation works best with finite model programs<br />

that can be explored completely. In Chapter 12 we introduce on-the-fly testing,<br />

where the test case is generated as the test executes. On-the-fly testing is an attractive<br />

alternative for “infinite” model programs that cannot be explored completely.<br />

In this chapter we test closed systems where the tester controls every action.<br />

In Chapter 16 we test reactive systems, where some actions are invoked by the<br />

environment.<br />

8.1 Offline test generation<br />

The offline test generator otg explores a model program to create a finite state<br />

machine (FSM), traverses paths through the FSM, and saves the paths in a file so<br />

they can be used later. The paths define a collection of program runs. The collection<br />

is called a test suite; each run in the collection is a test case. Later, the implementation<br />

can execute the test suite, under the control of a test runner. 1<br />

The otg tool has one traversal algorithm built in. The algorithm eliminates all<br />

paths to dead states, then traverses the remaining paths using a postman tour that<br />

covers the entire graph of the FSM in the minimum number of steps, visiting each<br />

state and taking each transition at least once.<br />

1 A complete command reference for otg appears in Appendix B.2.<br />

more free ebooks download links at:<br />

http://www.ebook-x.com<br />

137

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

Saved successfully!

Ooh no, something went wrong!