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