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.

Appendices 291<br />

}<br />

{<br />

}<br />

static Set pendingRequests = Set.EmptySet;<br />

[StateFilter]<br />

static bool LimitNumberOfRequests()<br />

{<br />

return pendingRequests.Count < 4;<br />

}<br />

State filters are often used in conjuction with a [Feature] attribute so that they<br />

may selectively applied.<br />

A.1.9 State properties<br />

The [StateProperty] attribute indicates additional information that may be used by<br />

the exploration algorithm when deciding which states to explore. It may be applied<br />

to a method, property, or field. Properties are named. If a name is not given in the<br />

attribute, the property name defaults to the target name.<br />

namespace My<strong>Model</strong>Program<br />

{<br />

static class Contract<br />

{<br />

static Set pendingRequests = Set.EmptySet;<br />

}<br />

A.1.10 Requirements<br />

}<br />

[StateProperty("NumberOfRequests")]<br />

static int RequestCount()<br />

{<br />

return pendingRequests.Count;<br />

}<br />

It is sometimes useful to document the link between the elements of a model program<br />

and a natural language requirements document. <strong>We</strong> use an attribute in the form<br />

[Requirement("string")] for this purpose. The string string provides traceability<br />

back to an external requirement source.<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!