Wednesday, 2 September 2009

Sproing: FitNesse-Spring integration

Sproing wires up FitNesse fixtures into Spring by loading any application context files you specify and then wiring the fixture into it, allowing you to inject beans into the fixture at runtime.

The fixture needs to implement SpringWirableFixture and extend your chosen FitNesse fixture. It is wired
using the AutowireCapableBeanFactory.AUTOWIRE_BY_NAME strategy - it needs to do this to work properly with
FitNesse, so your fixtures need to have setter methods with the same names as the beans you want to wire up

You need to create a subclass of AbstractFixtureWirer and implement the getPaths() method to return the paths of the spring
application context files you want to wire up

For example:

public class YourAppFixtureWirer extends AbstractFixtureWirer {

public String[] getPaths() {

return new String[] {


To wire up your fixture, all you need do is create a default constructor (or setUp() method if using a fixture that
has one) and create a new instance of your overridden {@link AbstractFixtureWirer} class

For example, using YourAppFixtureWirer in the above example:

public class TestFixture extends ColumnFixture implements SpringWirableFixture {

public TestFixture() {
new YourAppFixtureWirer().wire(this);


FitNesse will call the default constructor, wiring up your fixture with the bean factory. Provided you have defined
public setter methods for any spring dependencies your fixture needs, and called them the same names as described
above, spring will inject these at runtime. You can then write your fixture methods as normal

It can be downloaded from sourceforge

No comments: