WritingFixtures

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 usersarah
usersarahcreatesfitroom
usersarahentersfitroom

Some Example Code


public class ChatStart extends fit.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 roomfit
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 userrick

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