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.

10 <strong>Model</strong>ing Systems<br />

with Structured<br />

State<br />

In the previous chapters we saw model programs that could be exhaustively explored<br />

into their corresponding finite state machines. In this chapter, we will show how the<br />

concept of a model program can cover larger, even infinite, numbers of states and<br />

transitions.<br />

10.1 “Infinite” model programs<br />

To understand this we can introduce data types like integers and strings to our model<br />

program. Unlike the data types we have considered up to this point, numbers and<br />

strings are drawn from very large, or even infinite, domains.<br />

Here is an example of a model program that has a number of states bounded only<br />

by the size of the integer data type:<br />

namespace Counter1<br />

{<br />

static class Contract<br />

{<br />

static int counter = 0;<br />

}<br />

[Action]<br />

static void Increment() { counter = counter + 1; }<br />

[Action]<br />

static void Decrement() { counter = counter - 1; }<br />

}<br />

What’s interesing here is that even with just two actions and no parameters, the<br />

number of states may grow without limit, or at least without a computationally<br />

feasible limit.<br />

more free ebooks download links at:<br />

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

155

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

Saved successfully!

Ooh no, something went wrong!