Quantcast

Best Functional Test plugin for RESTful services

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Best Functional Test plugin for RESTful services

redcoat
We have a "headless" app that provides RESTful services that serve XML and binary resources.

We need to chose some tools to help us write Functional tests.  I see a list of plugins here: <a href="http://grails.org/doc/latest/guide/testing.html#9.3 Functional Testing">http://grails.org/doc/latest/guide/testing.html#9.3 Functional Testing.

Can anyone provide any recommendations on what to use in our situation?  Most of our tests will include HTTP GETs and POSTs and validating the XML that is returned.

Also, what do most people use to handle database state during functional tests?  Do all your tests initalize the database with a snapshot?  If so, how do you generate & manage them in the midst of a lot of flux?  If not, how do you guarantee db state?  Do you run a set of tests against the same snapshots?

Advice welcome,

cheers,

David

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Best Functional Test plugin for RESTful services

bksaville

Comments inline

 

From: David Hay [mailto:[hidden email]]
Sent: Wednesday, June 27, 2012 11:40 AM
To: [hidden email]
Subject: [grails-user] Best Functional Test plugin for RESTful services

 

We have a "headless" app that provides RESTful services that serve XML and binary resources.

 

We need to chose some tools to help us write Functional tests.  I see a list of plugins here: <a href="http://grails.org/doc/latest/guide/testing.html#9.3 Functional Testing">http://grails.org/doc/latest/guide/testing.html#9.3 Functional Testing.

 

Can anyone provide any recommendations on what to use in our situation?  Most of our tests will include HTTP GETs and POSTs and validating the XML that is returned.

 

We use geb just because we have a few HTML pages as well and we can do functional testing with a REST client in regular functional tests (that extend Specification instead of GebReportingSpec).  Beware of using geb if you’re using http-builder/release plugin though, there is a ticket with instructions on how to get it working but the dependency mess is a problem.  I would also recommend the spock functional plugin even though I haven’t tried it myself, it’s pretty recent and I haven’t had much luck with other functional testing plugin.  Using either of these in combination with the rest-client-builder plugin is one of the best bets for now (or http-builder if you’re not doing geb).

 

Also, what do most people use to handle database state during functional tests?  Do all your tests initalize the database with a snapshot?  If so, how do you generate & manage them in the midst of a lot of flux?  If not, how do you guarantee db state?  Do you run a set of tests against the same snapshots?

 

We actually clean out our database before each call using the remote plugin, but then again, we’re using mongo where it’s a lot easier to do so and relationships can be a little more undefined.  Otherwise I would use the build-test-data plugin in combination with the fixtures plugin to load them during the functional testing phase – either right in the setup of your test class or in the Bootstrap (needs some work to get the current test phase using the _Events.groovy) file.

 

I know that’s a lot of convoluted advice, but hopefully it helps you out.

 

Advice welcome,

 

cheers,

 

David

 

Loading...