We use Selectors that return a list of objects all over the application and of course we want to use them in our Fitnesse tests.
To be able to do so, we introduced a new kind of Fixture that uses reflection to fill a map – one entry for each result of the selector. Basically, all we did was expand Fitnesse’s RowFixture and override the query() Method:
-
@Override
-
final List<Map<String, Object>> result =
-
new LinkedList<Map<String, Object>>();
-
for (ValueObject each : executeSelector()) {
-
Map<String, Object> row = new HashMap<String, Object>();
-
}
-
}
-
}
-
}
executeSelector() is abstract and has to be overwritten in each subclass of this Fixture to return whatever is needed. In Fitnesse, you can directly use the the field names:
|User Selector| |NAME|AGE|GENDER| |Daisy|32|female| |Donald|34|male| |Minnie|25|female|
That way we are able to write slim fixtures and don’t have to waste time writing getters for each field as we did before.



