FitNesse. UserGuide. FitLibraryUserGuide. DoFixture.
WritingFixtures [add child]

Actions and Methods

Each action in a DoFixture table is mapped directly to a method in the fixture (we'll expand this model in FixtureDetails).

Eg, consider the first few tables:
ChatStart
connect user sarah
user sarah creates fit room
user sarah enters fit room

Some Example Code


public class ChatStart extends fitlibrary.DoFixture {
private ChatRoom chat = new ChatRoom();

public ChatStart() {
setSystemUnderTest(chat);
}
public boolean connectUser(String userName) {
return chat.connectUser(userName);
}
public boolean userCreatesRoom(String userName, String roomName) {
return chat.userCreatesRoom(userName,roomName);
}
public boolean userEntersRoom(String userName, String roomName) {
return chat.userEntersRoom(userName,roomName);
}
...


The next table checks a list.

users in room fit
name
sarah

The first row is an action, which corresponds to the method usersInRoom() which returns a ParamRowFixture[?]. This fixture object interprets the rest of the table.

	...
public Fixture usersInRoom(String roomName) {
return new ParamRowFixture(chat.usersInRoom(roomName).toArray(),User.class);
}
...


Each following table is handled by the initial DoFixture:

connect user rick

This means that each table doesn't need an explicit fixture, so actions can be split up easily. Because actions may return a fixture object for the rest of the table, that object can be created with all the appropriate information. This avoids the needs for global variables for communication between fixtures.

FixtureDetails