Of course, you donβt want to change your business logic to make your tests look better. The good news, however, is there is a way to do this, which is not difficult, but not as simple as passing a format specifier.
Try to think of your Fit Fixture as a service boundary between FitNesse and your application code. You want to define a contract that does not have to be changed if the details of the implementation of your SUT ( S ystem Under T est).
Let's look at a simplified version of your business object:
public class BusinessObject { public float Percent { get; private set; } }
Due to the fact that RowFixture works, we need to define a simple object that will work as a contract. Usually we used the interface, but this will not serve our purpose here, therefore a simple DTO ( D ata T ransfer O bject).
Something like that:
public class ReturnRowDTO { public String Percent { get; set; } }
Now we can define a RowFixture that will return a list of our custom DTO objects. We also need to create a way to convert BusinessObjects to ReturnRowDTO. In the end, we have a Fixture that looks something like this.
public class ExampleRowFixture: fit.RowFixture { private ISomeService _someService; public override object[] Query() { BusinessObject[] list = _someService.GetBusinessObjects(); return Array.ConvertAll(list, new Converter<BusinessObject, ReturnRowDTO>(ConvertBusinessObjectToDTO)); } public override Type GetTargetClass() { return typeof (ReturnRowDTO); } public ReturnRowDTO ConvertBusinessObjectToDTO(BusinessObject businessObject) { return new ReturnRowDTO() {Percent = businessObject.Percent.ToString("%")}; } }
Now you can modify the underlying BusinessObjects without breaking the actual Fit Tests. Hope this helps.
Josh
source share