FitNesse. UserGuide. FitLibraryUserGuide.
MetaTypeAdapter [add child]
(This is an advanced topic that concerns few people.)


Core Fit assumes that each cell of a table contains text. This text is converted into a Java object (or primitive value) by a TypeAdapter so that the value can be used in the test (eg, assigned to an instance variable or used to check whether the right value was returned from the fixture). The TypeAdapter chosen depends on the type of the corresponding method argument, method return type, public instance variable type, etc.

A TypeAdapter is actually responsible for:
Any tags in the text of a cell are removed before it is parsed into a value.

See Chapter 37 of the FitBook for further discussion.


FitLibrary extends this idea so that it can treat the text inside a cell in a special way (such as to treat the contents as a list, or table, etc). FitLibrary does this if there is a MetaTypeAdapter associated with the type of a method argument (or whatever), in which case it passes all of the contents of the cell (including tags) to the MetaTypeAdapter.

Here is a simplified account of MetaTypeAdapters:
In fact, MetaTypeAdapters are more general than this. Most MetaTypeAdapters actually pass responsibility for parsing to the type concerned, through that type's static Object parse(String) method. This can result in quite different parsing and testing for equality. Eg, GraphicTypeAdapter may pass responsbility to a ImageNameGraphic (which simply compare the file names), DotGraphic (which compares the underlying text in a Dot file), or a ObjectDotGraphic (which builds Dot graphs automatically out of graphs of objects).

You can provide your own subclasses to handle parsing and equality however you like. For example, you might choose to compare the pixels within two images that are referenced through a IMAGE.