Testing Grails application with Cucumber

161 views
Skip to first unread message

Eirik L.

unread,
Jan 27, 2010, 6:13:39 AM1/27/10
to Cukes
Hi all.

Have anyone successfully tested grails applications with Cucumber?
I have a Grails application which I want to test using Cucumber. The
way I was planning to do this was to make step-definitions which sends/
gets data from the controllers.

Regard

- Eirik

John Stoneham

unread,
Jan 27, 2010, 6:27:02 PM1/27/10
to cu...@googlegroups.com

Eirik,

I'm not aware of anyone who's done this so far. I've had a
grails-cucumber plugin in the works for a few months but have had
almost no time to work on it, so it's not ready yet.

- John

--
John Stoneham
ly...@lyrically.net

Eirik L. Wang

unread,
Jan 28, 2010, 4:04:25 PM1/28/10
to cu...@googlegroups.com
John

How far are you in the progress?
The thing is that I'm helping a student project who want to use Cucumber to test their application. So if you need any help finishing it, I might be of some help.

 - Eirik


--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cu...@googlegroups.com.
To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.


John Stoneham

unread,
Jan 28, 2010, 11:08:31 PM1/28/10
to cu...@googlegroups.com
On Thu, Jan 28, 2010 at 4:04 PM, Eirik L. Wang <eirik...@gmail.com> wrote:
> How far are you in the progress?
> The thing is that I'm helping a student project who want to use Cucumber to
> test their application. So if you need any help finishing it, I might be of
> some help.

Everything I've got ready to push I put on GitHub, which I see you
found. It's not really enough to do anything with, just me playing
around with environment settings and getting some basic steps running
from Gant. The hard part is the classloader integration. I hope to
have some time this weekend, though.

--
John Stoneham
ly...@lyrically.net

aslak hellesoy

unread,
Jan 29, 2010, 6:51:37 AM1/29/10
to cukes

I made a serious attempt to make Cucumber work with Grails a coouple
of months ago. In order to be able to roll back DB transactions in an
After block I tried to make Cucumber run in the same JVM as Grails
itself. This turned out to be very complicated. I couldn't figure out
how to invoke Grails controllers programmatically without starting a
Grails server in a different window/JVM. If I remember correctly, the
problem was that I couldn't get hold of the database connection
because Grails/Spring hides this behind layers and layers of class
loaders and complex framework stuff.

I did succeed with a Grails server in a separate window/JVM and
Cucumber accessing it over plain HTTP (using celerity IIRC), but this
is a far from ideal solution. It's slow, it requires occasional
restarts of the Grails server, and worst of all - there is no shared
database connection, so data in the DB remains between each scenario,
making it practically impossible to write scenarios that will behave
in a predictable manner. It could work if someone implemented
something similar to DatabaseCleaner [1] for Grails, but the drawbacks
of slowness would still be a hurdle.

One option I wanted to try out, but never had the time to try out, was
to start Cucumber from Grails instead of starting Grails from
Cucumber. This would make it possible to run them both in the same
JVM, and to have access to the same DB connection, making it possible
to open a transaction in a Before hook, and roll it back in an After
hook. Launching Cucumber from Grails could probably be done in one of
the Grails app's "startup" files (don't remember exactly how those
work, but I'm quite sure they exist).

I'd be interested in helping out getting this to work. If you set up a
simple Grails project with a single model and controller on GitHub we
could collaborate there. If we get it to work we could move it under
cuke4duke/examples/grails. (There is already some stuff there, left
over from my previous failed attempts).

I also recommend you read through Matt's post:
http://groups.google.com/group/cukes/browse_thread/thread/a403367146dea32b
- some of the Grails challenges are the same as he describes in that
post.

[1] http://github.com/bmabey/database_cleaner

Cheers,
Aslak

> Regard
>
>  - Eirik

Jim Morris

unread,
Feb 1, 2010, 3:27:33 AM2/1/10
to Cukes
Yes I use cucumber to do integration testing of my Grails app...

http://github.com/wolfmanjm/wolfmanblog-grails/tree/master/test/features/

Basically I use webrat and mechanize to access the grails app via
http.

I use a simple db helper using sequel to setup the database before and
after the tests.

This is basically final integration testing over the wire using http.
Its pretty simple to do it this way.

I did have to make some minor modifications to webrat to use mechanize
properly, and I did submit the patches to the Webrat project, but they
have not been picked up yet.

> I also recommend you read through Matt's post:http://groups.google.com/group/cukes/browse_thread/thread/a403367146d...

Reply all
Reply to author
Forward
0 new messages