Even if you don't practice test-driven development, you are certainly familiar with the JUnit family of testing frameworks (including ports to other languages like cppunit, NUnit, or independent but similar approaches like TestNG).
This post is about the
Fit framework family, which has a somewhat different focus and is not just another JUnit clone. In a nutshell, Fit represents expected and actual test results in tables, and you do not have to be a programmer to read or write them.
The following table has one column of inputs and two columns of outputs:
Each row of this table can be regarded as an acceptance test case. You can feed this table to a given system and compare the outputs:
It's only a couple of weeks ago I was introduced to Fit in my current project, and I must admit my first thought was "Why don't you just write a
@Parameterized JUnit test?"
The answer is, JUnit is for developers, and developers only; Fit is for customers
and developers.
You still need a developer to implement the skeleton logic of a test (called fixture in Fit), but anyone can write new test cases by adding rows or columns to a given Fit table.
The Fit method and the original Java implementation were created by Ward Cunningham in or around 2002, the project is hosted on
Sourceforge and has been inactive since 2008.
The
Fitnesse project integrates Fit with a Wiki, it includes a modified version of the original Fit implementation and is under active development. However, Fit and Fitnesse are incompatible, Fit lets you write your test tables in plain old HTML, whereas Fitnesse supports its own Wiki syntax only.
Our project has a fair amount of plain old HTML Fit tests, and our production code uses Spring, so it was a fairly natural idea to inject Spring beans from the system under test into our Fit test code.
Spring is just one (and not really my favourite) framework for dependency injection (and lots of others things). so I inevitably started thinking about how to use Fit together with Java EE or OSGi.
Thinking was followed by coding (yeah, it can be the other way round sometimes...), and this led to a project called
reFit hosted on Google Code.
reFit is based on the latest Fit sources from SourceForge, it provides up-to-date Maven artifacts on Maven Central and integrations with Java EE 6, Spring and OSGi Declarative Services. The Java EE integration reuses parts of my
jeeunit project.
In addition, reFit lets you run Fit tests under a JUnit wrapper or from a Maven plugin, both with or without Spring integration. reFit includes ready-to-run example code for Glassfish 3.1, Spring 3, Equinox and Weld SE.
There's more to come, I'm currently experimenting with a Web frontend and a WYSIWYG HTML editor.
For more details, check out the
reFit Wiki.