Grails WebTest Plugin 1.2.0 Released
Update: latest version is now 1.2.3 containing some installer improvements and test generation bug fixes
The latest version of the Grails WebTest plugin is now available in the main repository. It is a major update to integrate better with the grails test-app hooks and is built using Grails 1.2-M2 (it is backwards compatible with 1.1+). As such there are some manual upgrade steps required (see release notes below). On the plus side, tests will now run as part of test-app and can also access domain classes and plugin code via the groovy step provided by WebTest
There are some trade-offs between using the old run-webtest script and the new test-app support which are outlined below. Hopefully subsequent releases can move all functionality over to the test-app script. Please raise any issues in JIRA against the webtest plugin component.
Release Notes
- The plugin will move your webtests on install to test/webtest. You will need to rename them to *Tests.groovy for test-app to run them.
- You will need to replace test method declaration that use def test* with void test* for test-app to run them.
- The classSetUp/TearDown methods supported by run-webtest won't work via test-app as they are not supported by junit.
- Custom suites run via the -suite option will only work via run-webtest.
- Access to domain classes/plugins etc only available via test-app (for now). You can access domain classes etc during a test by using a groovy step. Groovy code in the actual test method will run as the steps are being built, not as the steps are run.
- The -nostart option not available via test-app. Hopefully support for this will be added to test-app in the future
- TestSuite.groovy may need to be updated to scan the new location and also for *Tests.groovy in order for run-webtest to work with the renamed tests.
- The way test-app and run-webtest filter tests using command line arguments is different. Check the documentation if you're unsure as to how they work.

Comments
Problem with webtest + httpbuilder though!
Love the webtest plugin, and it integrates really smoothly with the test-app phase now.
However there is still a long-standing problem with the xerces+xml-api jars which means I have to download the plugin and hack it to work with a project where I use HTTPBuilder!
Now is it your fault, or is it HttpBuilder's fault that there is a conflict in the classloader - we've had this for a year now? There must be a way to resolve this without deleting jars :D
Ant
The xerces jars come as part
The xerces jars come as part of the WebTest distribution zip. I could update the plugin install script to delete them if they are already provided by Grails core.
Another option now that Grails is getting tighter integration with Ivy is to use Ivy to pull in Webtest rather than manually downloading the distribution and then exclude the xerces dependency of WebTest.
If you raise a JIRA with the details of the JAR conflicts hopefully it could be fixed with the next release of the plugin.
how can I insert data in the setUp method?
Hi how can i insert/delete data in the setUp/TearDown methods in order to restart the environment before/after each tests?
thanks
You can use a groovy step to
You can use a groovy step to call the Fixtures plugin
thanks
Lee
Great work
Great work Lee - nice to see some 1.2 stuff coming through