I’ve previously written about Fit, which is a testing platform (implemented in various languages from Java to C#) that facilitates communication between those who write requirements and those who turn them into executable code. Having dug deeply into the Java implementation many times before, I was eager to see how quickly I could get things working in Fit’s C# version– needless to say, the authors of Fit have managed to practically port the exact code into C#, making the learning curve for those coming from Java virtually non-existent.

I created a quick Trender class, which has simple logic for determining the trend of two numbers (i.e. either the pattern is increasing, decreasing, etc). I then created a simple column table and a corresponding ColumnFixture type, dubbed TrenderFixture.

For example, the column table is defined below with three columns- the first two corresponding to input values and the last column corresponding to the expected result.

The top row of the table defines the fixture which will be matched with the table’s data by Fit. In this case, Fit will attempt to find the TrenderFixture class in the fit.net_example namespace.

TrenderFixture, shown below, extends Fit’s ColumnFixture and has two public properties corresponding to the two input values from the table above. The class also defines a Trend method, which corresponds to the last column in the table above. This method is accordingly invoked with the first two row values. Internally, the Trend method then invokes the Trender class and returns the result, which Fit will compare to the expected result defined in the table.

using System;
using fit;

namespace myfit.example
{

 public class TrenderFixture : ColumnFixture
 {
  public double value1;
  public double value2;

  public string Trend()
  {
    return Trender.Trend(value1, value2);
  }
 }
}

Invoking the runFile executable (which is bundled with the Fit .NET distribution) with the familiar input file, output file and desired assembly will yield a green table if all goes well as shown below.


Fit is an excellent framework for bridging the communication gap that seems to divide developers from stakeholders and as you can see, it is extremely easy to use.

For more information on Fit, see “In pursuit of code quality: Resolve to get FIT”.