Over a million developers have joined DZone.

Grails Gets Some FitNesse Finesse

· Agile Zone

Learn more about how DevOps teams must adopt a more agile development process, working in parallel instead of waiting on other teams to finish their components or for resources to become available, brought to you in partnership with CA Technologies.

Erik Pragt, who also wrote DZone's "Getting Started with FitNesse" Refcard, is the author of a new Grails plugin that brings the power of FitNesse acceptance testing to Grails apps. 

Clean Code author Bob Martin helped create the software development collaboration framework called FitNesse, which "enables customers, testers, and programmers to learn what their software should do, and to automatically compare that to what it actually does do."  The open source framework acts as an acceptance testing tool, a wiki, and a web server with no configuration setup.  

Let's start by installing the plugin:
$ grails install-plugin fitnesse
Once you start up the Grails app, a FitNesse server will also start internally and connect the Wiki with the app.  

FitNesse Fixtures, which should not be confused with Grails Fixtures, provide a bridge between the FitNesse Wiki and the System Under Test (SUT).  FitNesse Fixtures more closely resemble Grails artifacts with similar features like dependency injection and hot reloading.  A FitNesse directory in the grails-app directory should be used for creating fixtures.

Here's a Wiki test example.  It consists of a fixture name (loan calculator), headers (income, debt), and the body of the table:

|loan calculator       |
|10000 |500  |A        |
|5000  |10000|C        |

and this is the Fixture bridge:
class LoanCalculator {
// Input parameters
int income
int debts
// Output parameter
String category
// Dependency Injected
def loanCalculationService
void execute() {
this.category = loanCalculationService.calculateLoanCategory(income, debts)

The Wiki contains the tests (in table form).  The plugin currently supports the following tests:

Decision Table - Supplies the inputs and outputs for decisions. This is similar to the Fit Column Fixture.
Query Table - Supplies the expected results of a query. This is similar to the Fit Row Fixture.
Script Table - A series of actions and checks. Similar to Do Fixture.
Import - Add a path to the fixture search path.

Six other tables may work, but haven't been tested yet.

Other features:

  • Grrovy and FitNesse support strings as methods
  • Both support default arguments
  • Automatic reloading of Fixtures in Grails

Download the plugin here.

Discover the warning signs of DevOps Dysfunction and learn how to get back on the right track, brought to you in partnership with CA Technologies.


Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}