Spock Integration Specs in Grails 2.0

100 views
Skip to first unread message

Marco Vermeulen

unread,
Jan 26, 2012, 7:15:53 AM1/26/12
to Spock Framework - User
Hey guys,

I've been migrating our Grails projects to 2.0. In the process, most
of my pain seemed to be in migrating the spock integration specs.

My problems stem from the fact that my GORM fixtures aren't being
cleaned up after each test method. Where this really surfaced most was
in the scenarios where my domain objects had an assigned id. my setup
method would try creating a new instance of the domain class, and
would blow up with a unique constraint violation on the id field.

I've even noticed that fixture isn't cleaned up between multiple
integration specs, causing all sorts of funky interactions. One spec's
fixture will cause constraint violations in another fixtures
construction.

To take it yet another step further (haha, yes there is more!), is
when you run tests in the interactive console. The fixture seems to be
kept alive between multiple test runs from the cli.

Is there something that can be done (besides implementing lengthy
cleanup methods on each spec) to clear out the fixture between test
runs?

Cheers,
Marco.

Luke Daley

unread,
Jan 26, 2012, 10:17:41 AM1/26/12
to spockfr...@googlegroups.com

The only cleanup that happens is that everything inside the feature
method happens inside a transaction which is rolled back. This means
that anything persisted outside of that transaction won't be cleaned up,
but this is not new so I suspect it's something else.

If you can send me a sample app that shows the problem I'll take a look.

Marco Vermeulen

unread,
Jan 26, 2012, 12:31:51 PM1/26/12
to Spock Framework - User
No worries, looks like we were jumping on the wrong band wagon.

It turned out to be a bug in gorm. A weird interaction when you use a
unique constraint and an assigned primary key together. I'll try
replicating it and open a jira for grails.

Thanks for the help,
Cheers,
Marco.
Reply all
Reply to author
Forward
0 new messages