Thanks Lee. So it looks like there isn't a clean way to do what I'd like to do, but there are a couple workarounds so we'll just keep doing things the way we're doing them for the time being.
Would it be worthwhile filing a JIRA issue regarding the fact that newAntBuilder.group() doesn't execute its child tests under newAntBuilder but instead under the default AntBuilder (ie. ant) of it's test class? Or is this not something that will ever get worked on? Cheers, Dave On Fri, Jul 24, 2009 at 9:22 PM, Lee Butts <[email protected]> wrote: > Hi David, > > I use test cases that extend WebTest and it all works fine for me using > 1.1.5.1 > > e.g. > > class MyTestCase extends WebTest{ > > def login(){ > invoke('/') > setInputField name:'username', value:'testuser' > .... > } > } > > I agree that your parents will get quite large. The only other option is to > put it in a helper class and somehow pass in a reference to the current ant > builder (from WebTest.ant) > > cheers > > Lee > > 2009/7/25 David Koo <[email protected]> > > Hi Lee, >> >> We're on 1.1.4.2 and still having this problem. We had the same problem >> with 0.6 as well. >> >> We have tried parent test cases as well, but if we try to put all common >> code into parent test cases, we'll probably end up with some massive parents >> (or duplicating code into multiple parents). >> >> Can you replicate this issue on your end? Should I file a JIRA for it? >> >> Thanks again, >> Dave >> >> >> On Thu, Jul 23, 2009 at 7:57 PM, Lee Butts <[email protected]> wrote: >> >>> Hi, >>> >>> What version of the plugin are you using? >>> >>> I think since 1.1.4 all calls should be delegated to AntBuilder >>> automatically and you shouldn't need to prefix everything with ab. >>> >>> I normally refactor common code into a parent test case which seems to >>> work well. >>> >>> cheers >>> >>> Lee >>> >>> 2009/7/24 David Koo <[email protected]> >>> >>> Hi there, >>>> >>>> (My apologies if you receive this twice, I'm not sure if it sent the >>>> first time since I had just joined the mailing list) >>>> >>>> >>>> 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 >>>> >>>> >>> >> >

