Hi there,
I'm trying to better organize & re-use my WebTests (which I'm writing in
Groovy with support from the Grails WebTest plugin).
Currently, I'm able to to call a method in one webtest class from another
webtest class by passing the AntBuilder instance as follows:
public class MyTest extends WebTest {
def testSomething(){
def userTest = new UserTest()
userTest.login(ant)
}
}
This is fine, but my issue is in writing the login() method which currently
looks like this:
public class UserTest extends WebTest {
def login(AntBuilder ab) {
ab.group(description: "login") {
ab.invoke "/path/to/something"
ab.verifyText "some text"
ab.invoke "/path/to/something/else"
ab.verifyText "some other text"
.....
}
}
}
My issue is that it's quite tedious to have to put "ab." in front of every
single step in my test.
I read somewhere that you didn't need to specify the AntBuilder instance
inside a group so I tried doing that as follows but I got an exception
saying it couldn't invoke my test (when calling this method from
MyTest.testSomething() above):
def login(AntBuilder ab) {
ab.group(description: "login") {
invoke "/path/to/something"
verifyText "some text"
invoke "/path/to/something/else"
verifyText "some other text"
}
}
I'm wondering if there's another way to do this? Am I missing something?
Thanks,
Dave