Avoid conversions by supporting custom data types

DoFixture and SequenceFixture allow you to call business domain methods directly from tables (see Wrapping business objects with DoFixture and Can I use flow mode without weird method names?) without re-implementing these methods in the fixture. This significantly shortens the effort required to write and maintain tests. However, methods from business classes often handle other business objects, not just basic .NET types. In the second part of the book, we often use a username as a parameter of fixture methods and look for matching Player objects in the fixture code. If our fixture methods mostly convert table contents into business types, we can often simplify the code significantly by telling FitNesse how to create business objects directly. Instead of looking for the Player object every time, a fixture can receive it from the framework. We just need to provide a public static method Parse(String value) that converts strings into our business objects and override ToString and Equals methods to provide consistent conversion to and from strings. FitNesse can then create our business objects on the fly and pass them to methods directly.

Obviously, this cannot be done if the business method arguments are specified by interface, not by class.

[Tip]What if Parse is not available?

If you want to tell FitNesse how to use a third-party or system object, where you cannot add a Parse method, then you can implement a custom cell handler to provide the conversion.