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.

2 <strong>Why</strong> <strong>We</strong> <strong>Need</strong><br />

<strong>Model</strong>-<strong>Based</strong><br />

<strong>Testing</strong><br />

This chapter demonstrates why we need model-based testing, with a small but<br />

complete working example. <strong>We</strong> exhibit a software defect that is not detected by<br />

typical unit tests, but is only exposed by executing more realistic scenarios that<br />

resemble actual application program runs. <strong>We</strong> conclude that, in order to generate<br />

and check the realistic scenarios required for thorough testing, we will need more<br />

automation than is provided by the popular unit testing tools. <strong>We</strong> preview our testing<br />

techniques and show how they can detect the defect that the unit tests missed.<br />

This chapter concerns testing methods. <strong>We</strong> also have analysis methods that can<br />

detect errors that arise during specification or design. <strong>We</strong> demonstrate an example<br />

that motivates our analysis methods in Chapter 3.<br />

In this chapter, we also review some features of the technologies we use: the C#<br />

language, the .NET framework, and the NUnit testing tool.<br />

2.1 Client and server<br />

Suppose we are developing a laboratory instrument system comprising a temperature<br />

sensor connected to an embedded computer, a network, and another computer used<br />

for data storage and analysis (Figure 2.1). This is a client/server system. The server,<br />

a temperature-monitoring program, runs on the embedded computer. The client,<br />

a data-logging program, runs on the other computer. The programs communicate<br />

using the TCP/IP protocol, so the client could use the Internet to connect to a server<br />

in a remote factory or weather station.<br />

First we start the server program Monitor by typing a command at the embedded<br />

computer:<br />

Monitor 128.95.165.121 8023 1<br />

The command-line arguments are the IP address and port number that the server<br />

should use, and the number of successive client connections to accept before exiting.<br />

more free ebooks download links at:<br />

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

13

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

Saved successfully!

Ooh no, something went wrong!