Hi David, currently the WebTest plugin for grails (which I assume you are using?) forks WebTest in a seperate JVM which mean's you cannot access all the dynamic code normally availble within Grails.
The next release of the plugin should integrate better with the Grails test-app process and therefore have access to all the domain classes etc. But for now, the only thing I can think of is to get standalone GORM working by putting the jar in WEBTEST_HOME/lib. I've never tried standalone GORM so don't know what state it's currently in or how to use it. Otherwise perhaps look at trying to integrate DBUnit to help set up the DB state? cheers Lee 2009/9/2 David Koo <[email protected]> > Hi everyone, > > We're using WebTest, Groovy and Grails and have been pretty happy with this > combo so far. > > One thing that's slowing us down though is the amount of work required to > setup a WebTest (ie. get the DB in a specific state) using ONLY WebTest > steps (ie. clicking through our web app to create a certain type of user > before we test something using that user). Often our setup steps out number > our testing steps and this makes our test suites slow and lengthy to run. > > I've read that some people use dbunit and/or sqlunit to setup/teardown > their DB, but since we're using Grails we'd rather not write direct SQL code > if we don't have to (and there are other Java/Groovy classes we'd like to > leverage in our setup/teardown). > > Therefore, what we'd ideally like to do is do the setup/teardown in a > Groovy step by calling Grails' GORM dynamic persistence methods such as > MyClass.save(). I tried creating a simple 2-line groovy file as follows: > > import org.mypackage.MyDomainClass > def someVar = MyDomainClass.findByName("John") > > ....but I got a run-time error that the property "MyDomainClass" could not > be found, so it seems like WebTest is ignoring my import statement or can't > find the class file? Has anyone else successfully imported classes into a > groovy step? Eclipse resolves the import just fine at compile-time. > > If it's not possible to import external classes or to use GORM in a Groovy > step, then I does anyone know if it's possible to use GORM in a custom step? > If not, then I guess we'll have to setup/teardown our data via dbunit or > sqlunit but it would be a shame to have to bypass all the Grails goodness. > > Thanks, > Dave >

