Thanks again for the pointers . I am now able to resolve the issues and get a grails style webtest . The idea of a file scanner picking up tests is neat .
Thanks again . Regards Hari On Fri, Apr 25, 2008 at 2:07 PM, Marc Guillemot <[EMAIL PROTECTED]> wrote: > Hi, > > WebTest should provide some facilities to write tests as Groovy code. I > have some ideas concerning this but nothing is ready. > > In the mean time, you can have a look at how it is done in > Grails-Webtest Plugin > > > https://svn.codehaus.org/grails-plugins/grails-webtest/trunk/src/groovy/grails/util/WebTest.groovy > > Concerning your errors: you need to pass your ant object to the method > > ant.webtest(name:'groovy: Test Groovy Scripting at creation time'){ > config(config_map) > steps(){ > login(ant) > println('Finished tests ') > } > } > ... > login(ant) { > ant.invoke(url:'https://xyz/abc.') > ant.setInputField(name: "xx", value: "t50") > ant.setInputField(name: "yy", value: "junk123") > ant.clickButton(name: "zz") > ant.verifyText(text: "AA") > } > > for a better reporting you can use a group like this: > login(ant) { > ant.group(description: "perform login") > { > invoke(url:'https://xyz/abc.') > setInputField(name: "xx", value: "t50") > setInputField(name: "yy", value: "junk123") > clickButton(name: "zz") > verifyText(text: "AA") > } > } > > this allows to have the appropriate delegate defined and therefore you > don't need to write ant.xxx for each step. I want to explore some tricks > with delegates to think that some trick > > Cheers, > Marc. > -- > Blog: http://mguillem.wordpress.com > > > Harihara Vinayakaram wrote: > > This is the groovy example I was using . > > If I replace the login() method with the contents of that method then > > things work . running the test as is gives an error > > > > > > Caught: : Unexpected exception caught: > org.apache.tools.ant.BuildException > > at test.run(test.groovy:17) > > at test.main(test.groovy) > > > > My groovy version is > > Groovy Version: 1.5.1 JVM: > > R27.3.0-106-83792-1.5.0_11-20070607-1618-linux-ia32 > > > > ############### > > def ant = new AntBuilder() > > def webtest_home = System.properties.'webtest.home' > > > > ant.taskdef(resource:'webtest.taskdef'){ > > classpath(){ > > pathelement(location:"$webtest_home/lib") > > fileset(dir:"$webtest_home/lib", includes:"**/*.jar") > > } > > } > > > > > > def config_map = [:] > > ['autorefresh'].each{ > > config_map[it] = System.properties['webtest.'+it] > > } > > > > ant.testSpec(name:'groovy: Test Groovy Scripting at creation time'){ > > config(config_map) > > steps(){ > > login() > > println('Finished tests ') > > } > > } > > > > login() { > > invoke(url:'https://xyz/abc.') > > setInputField(name: "xx", value: "t50") > > setInputField(name: "yy", value: "junk123") > > clickButton(name: "zz") > > verifyText(text: "AA") > > } > > > > > > > > On Fri, Apr 25, 2008 at 7:21 AM, Harihara Vinayakaram <[EMAIL PROTECTED] > > <mailto:[EMAIL PROTECTED]>> wrote: > > > > Hi > > The samples provide how to organize tests into manageable entities > > in a XML format . The XML entity is particulary useful (since I am > > generating the tests from an XSL transformation ) > > > > But I am moving my tests to groovy since I need to do a lot more > > housekeeping and doing them in ANT leads to a lot of verbose code. > > > > I would like some suggestions on how to do a corresponding > > organization of tests in groovy > > > > I tried to add a function in the end but that gives a > > BuildException . I tried to put them in a java class but then that > > class does not find the AntBuilder. > > > > It would be very helpful if the samples also contains a groovy > > format . > > > > Any other suggestions would also be helpful > > > > Regards > > Hari > > > > > > > _______________________________________________ > WebTest mailing list > [email protected] > http://lists.canoo.com/mailman/listinfo/webtest >

