Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Grails Gets Some FitNesse Finesse

DZone's Guide to

Grails Gets Some FitNesse Finesse

· Agile Zone ·
Free Resource

See why over 50,000 companies trust Jira Software to plan, track, release, and report great software faster than ever before. Try the #1 software development tool used by agile teams.

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       |
|income|debts|category?|
|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.

See why over 50,000 companies trust Jira Software to plan, track, release, and report great software faster than ever before. Try the #1 software development tool used by agile teams.

Topics:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}