Previous page: ActionFixture Next page: TableFixture Parent page: Basic FIT fixtures
RowFixture
RowFixture tests dynamic lists of objects. It will compare the expected list (FitNesse table) with the actual result (from fixture code) and report any additional or missing items.Table Format
The first row of the table is the fixture class name. The second row describes the structure of objects in the list (the properties or methods that you want to verify). All rows after that describe expected objects in the array.
!include -seamless SetUpFixture
!|RowFixtureTest|
|name|post code|
|John Smith|SW4 66Z|
|Michael Jordan|NE1 8AT|
Fixture class
The fixture class should extend fit.RowFixture and override the following two methods:- getTargetClass — returns the Type or Class object representing the type of objects contained in the array.
- query — returns the actual array of objects to be verified.
Java Source Code
package info.fitnesse.fixturegallery;
import info.fitnesse.fixturegallery.domain.Player;
import fit.RowFixture;
public class RowFixtureTest extends RowFixture{
public Class getTargetClass() {
return Player.class;
}
public Object[] query() throws Exception {
return Player.players.toArray();
}
}
.NET Source Code
using System;
using System.Collections.Generic;
using System.Text;
namespace info.fitnesse.fixturegallery
{
public class RowFixtureTest: fit.RowFixture
{
public override Type GetTargetClass()
{
return typeof(Player);
}
public override object[] Query()
{
return Player.players.ToArray();
}
}
}
Python Source Code
from fit.RowFixture import RowFixture
from info.fitnesse.fixturegallery.domain.Player import Player
class RowFixtureTest(RowFixture):
def getTargetClass(self):
return Player
def query(self):
return list(Player.players) #< Return copy of players
Notes
If the object has some properties that can be considered part of the identity (such as a primary key), list those properties to the left, before auxiliary properties. This will make error reports easier to read. Consider the Figure 1 — the error is absolutely the same in both cases, but because of the column order one test report clearly identifies the offending cell and the other just reports that a whole row is missing.Figure 1: RowFixture maps rows to objects from left to right
The query method does not allow you to pass any additional arguments. For more information on how to parameterise this list, see Fixture Arguments .
The order of elements in the list is irrelevant, RowFixture will ignore it.
Usage
Use RowFixture to test and verify lists of objects, or to execute a method on every object in the list.Do not use RowFixture when the element order is important. Use ArrayFixture instead (see ArrayFixture).
Previous page: ActionFixture Next page: TableFixture Parent page: Basic FIT fixtures
Add Child Page to RowFixture