Agile Zone is brought to you in partnership with:

Mitch Pronschinske is the Lead Research Analyst at DZone. Researching and compiling content for DZone's research guides is his primary job. He likes to make his own ringtones, watches cartoons/anime, enjoys card and board games, and plays the accordion. Mitch is a DZone Zone Leader and has posted 2576 posts at DZone. You can read more from them at their website. View Full User Profile

Grails Gets Some FitNesse Finesse

11.19.2010
| 15086 views |
  • submit to reddit
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.

Comments

Erik Pragt replied on Sun, 2010/11/21 - 2:17pm

Hi Mitchell, thanks for the excellent writeup! I've just published a blog about my Fitnesse plugin: http://www.jworks.nl/blog/show/85/grails-functional-testing-done-right Kind regards, Erik Pragt

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.