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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

256 <strong>Model</strong>ing Objects<br />

The most important part of the harnessing is the dictionary maintained by the<br />

harness. This dictionary keeps track of the correspondence between implementation<br />

objects and term labels of the model program.<br />

15.5 Abstract values and isomorphic states<br />

It is sometimes useful to think of certain values as being abstract. An abstract value<br />

in this sense is a value whose only operation is equality. For example, in the Payroll1<br />

model program of this chapter we might consider values of the Employee type to be<br />

abstract.<br />

When enumerating the possible states of a model program, it is often useful to<br />

exclude states that are structurally identical to a previously seen state except for<br />

their choice of term labels for abstract values. <strong>We</strong> call any two such states isomorphic<br />

states. The concept of isomorphism comes from mathematics and refers to a<br />

structure-preserving transformation.<br />

Let’s look at an example. If you were to examine the states of Figure 15.2, you<br />

would see that state 3 is the following:<br />

nextId = 3<br />

allEmployees = Set(Employee(1), Employee(2))<br />

salary = Map(Employee(1), 200, Employee(2), 0)<br />

State 4 is:<br />

nextId = 3<br />

allEmployees = Set(Employee(1), Employee(2))<br />

salary = Map(Employee(1), 0, Employee(2), 200)<br />

You probably noticed that states 3 and 4 are similar. Both contain one employee<br />

with salary 0 and another employee with salary 200. If you were to transform state<br />

4 by renaming Employee(1) to Employee(2) and vice versa, then you would end<br />

up with state 3. If Employee values are abstract, then states 3 and 4 are isomorphic<br />

states. In other words, two states are isomorphic if there exists a substitution of<br />

abstract values that makes them equal.<br />

In N<strong>Model</strong> we can mark the values of a data type as abstract by annotating the<br />

type declaration with an attribute:<br />

namespace Payroll1<br />

{<br />

[Abstract]<br />

class Employee : CompoundValue<br />

{<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!