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.

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

topics. When they do, the topic list appears the same as when last seen; any previous<br />

selections regarding message excerpts and sort order are still in effect.<br />

5.3 Preliminary analysis<br />

Writing a model program always begins with a preliminary analysis where we<br />

decide on the purpose of the model, choose the features to include in the model,<br />

select the level of abstraction, identify the actions, write some sample traces, and<br />

identify the state variables.<br />

During preliminary analysis we study the implementation. Depending on what is<br />

available, we might study the implementation’s requirements and design documents,<br />

or inspect its API or its code. In this example, we just observe its behavior.<br />

5.3.1 Decide on the purpose<br />

<strong>Model</strong>ing is a goal-directed activity; every model program has a purpose. <strong>We</strong> write<br />

a model program in order to answer some questions about the implementation (by<br />

testing or analysis). <strong>We</strong> have to formulate those questions before we can see how to<br />

write the model program.<br />

In this example, our questions arise from the observation that the newsreader<br />

presents several kinds of pages that can be formatted in various styles, and several<br />

options for selecting pages and styles. Our questions are: What options are available<br />

when a particular page and style is displayed? What page and style appears when<br />

the user selects a particular option?<br />

Our questions guide testing and analysis. To create a test suite, we express the<br />

questions this way: Are the intended options made available for each particular page<br />

and style? Does the intended page and style appear when each particular option is<br />

chosen? To perform liveness analysis, we ask: Is every option available (on some<br />

page)? Can every page and style be made to appear (by choosing some sequence of<br />

options)? Are there are any deadlocks (pages with no options) or livelocks (pages<br />

from which other pages cannot be reached)? To perform safety analysis, we ask:<br />

Are the options that are available on each page the ones that should be there? Is it<br />

possible to request some combination of page and style that doesn’t make sense?<br />

5.3.2 Select the features<br />

<strong>We</strong> usually do not model a large system with a single model program. Instead, we<br />

select a subset of related features that comprise a self-contained package of functionality.<br />

A large implementation can be covered by several small model programs<br />

that represent different subsets of features. Choose a feature subset that makes a<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!