Adding custom type converters to Slim (Java)
If you have a fixture whose methods take or return a class that is not one of the standard Slim types, you can add a customer type converter very easily. There are two different ways to do this.First, you can use the standard PropertyEditor mechanism. You can read about this in the Javadocs for PropertyEditor. In short, if you have a class named MyType you can create a class named MyTypeEditor that implements the PropertyEditor interface (usually by extending PropertyEditorSupport). That's pretty much it. There are three different search paths for this class, but I'll let you read about that in the Javadocs.
There is an example of this in fitnesse.slim.test.ZorkEditor
Or, you can use the lower level approach of registering a converter.
The converter must derive from fitnesse.slim.Converter.
As you can see this is pretty simple. Your derivative must implement the toString method to convert your type to a string; and it must implement the fromString method to convert the string into your custom type.
package fitnesse.slim;
public interface Converter {
public String toString(Object o);
Object fromString(String arg);
}
Then, in the constructor of first fixture to uses that type simply put the following line of code:
fitnesse.slim.Slim.addConverter(MyClass.class, new MyClassConverter())
The technique for other language platforms should be similar to this. Check the documentation of the Slim port for your platform.
Add Child Page to CustomTypes