Fit for Developing Software: Framework for Integrated Tests

Questions & Answers

Q1:

Is there a way to avoid having to copy the User data into UserCopy?

A1:

Yes, if name was made a public instance variable in the class User, it wouldn't be necessary to make a copy. Instead, the collection of users returned from chat.usersInRoom() could be passed directly to the ParamRowFixture in the method usersInRoom() in Listing 28.1. We can avoid copying such data with SetFixture, a new fixture, because it also handles properties, as we discuss in Section 28.2.

The interaction of the fixtures and the first five tables is illustrated in Figure 28.2. Fit creates the object of class ChatStart for the first table. As this is a DoFixture object, it interprets subsequent tables as the flow fixture object. The second table contains a single row, which is an action, so the method connectUser() is called in the flow fixture object.

Figure 28.2. Fit Runs the First Five TestDisconnect Tables

The actions in the third and fourth tables are treated in the same way. The method for the action in the first row of the fifth table returns a fixture, which interprets the rest of the table. The ParamRowFixture object refers to an actual collection with a single element in it, the UserCopy for anna.

In the next two sections, we progress through several reductions of the ChatStart code, making use of the automatic capabilities of DoFixture.

    Категории