Before I delve into the technical details of test first development, I would like to discuss something that I came across today, a Framework for Integrated Testing (FIT). This really falls in the User Acceptance Testing category. The idea behind fit is that you can get customers (or BAs) to give you documentation in a tabular format that can be used for unit testing. Given that most people are familiar with and comfortable with working with tables in Excel and Word you can get them to put down the requirements in a format that they understand but is also useful for testing. A FIT document may look like the one below:
| eg.Division |
| numerator |
denominator |
quotient() |
| 1000 |
10 |
100.0000 |
| -1000 |
10 |
-100.0000 |
| 1000 |
7 |
142.85715 |
| 1000 |
.00001 |
100000000 |
| 4195835 |
3145729 |
1.3338196 |
The way FIT works is to look at an HTML table (possible exported from a MS Office product) and using that as a test fixture. A developer may have to do the actual test mapping, but the idea is that both the input and the output will be in a format understandable by normal users. This is what the test fixture for the above test would look like:
public class Division : ColumnFixture
{
public float numerator;
public float denominator;
public float quotient()
{
return numerator / denominator;
}
}
The fit framework matches the column names with the object property names and executes the quotient method. Pretty cool. A .Net version of the framework can be downloaded from here.