ok, I'm convinced. (never thought it would be necessary to convince me using Groovy ;-))
Dierk > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Marc Guillemot > Sent: Donnerstag, 10. Mai 2007 21:08 > To: [email protected] > Subject: Re: [Webtest] Grails like Groovy testing in non-grails project > > > Hi Andre, > > I believe too that WebTest should contain a base WebTestCase class to > allow writing tests à la Grails. I've tried once to convince Dierk to > include in WebTest distribution some stuff he wrote for Grails but he > told me that it was too Grails specific to be interesting (and that > "normal" WebTest users wouldn't not be interested). Your email shows > that I have to try again to convince him. > > I don't understand why you start building your webtest test cases with > the ant builder within an ant script (where you perform a taskdef for > tasks already defined in the "main" ant project). > > In fact you can just write your own base WebTestCase using an ant > builder that does just what is done in Grails or what is done in > WEBTEST_HOME/webtest.xml (lib/useWebTest.xml is deprecated and will > disappear). The smartest way would be to import this file in current > AntBuilder but this doesn't work currently (see recent discussion in > Groovy User mailing list). In the mean time you have to do it by > yourself ;-) > > Marc. > > Andre Schaefer wrote: > > Hello all, > > > > I just startet to use Canoo WebTest to functionally test some web > > applications. I did use the auto generated tests in a grails project > > beforehand. > > > > I understand, that I can use groovy scripts in groovy steps from an xml > > test definition like explained here: > > http://webtest.canoo.com/webtest/manual/groovy.html > > > > However I find the approach, grails generated, i.e. test classes > > extending grails.util.WebTest very elegant. > > > > Is there a chance to use grails.util.WebTest outside of a grails > > project? How would I do that? > > > > Here is the minimal example I use for now, wich runs but feels "clumsy" > > in comparison: > > > > build.xml: > > /-- > > <project name="BI IDEA Use Case Tests"> > > <property name="webtest.resultpath" value="webtest-results" /> > > <property name="webtest.resultfile" value="results.xml"/> > > <property name="webtest.resultfile.html" value="results.html"/> > > <property environment="env"/> > > <property name="env.WEBTEST_HOME" location="/opt/webtest"/> > > > > <property name="webtest.home" location="${env.WEBTEST_HOME}"/> > > <property name="testInWork" value="main"/> > > > > <description> > > <![CDATA[ > > Invoke the webtest scripts to invoke > functional webtests on the > > Interface > > ]]> > > </description> > > <import file="${webtest.home}/lib/useWebTest.xml" /> > > > > </project> > > \-- > > > > main.xml: > > /-- > > ... > > <project name="testMe" basedir="." default="main"> > > <property environment="env" /> > > <import file="${env.WEBTEST_HOME}/lib/taskdef.xml" /> > > > > <target name="main"> > > > > <webtest name="googletest"> > > &config; > > <steps> > > <groovy replaceProperties="false" > file="GoogleStep.groovy" /> > > </steps> > > </webtest> > > </target> > > > > </project> > > > > GoogleStep.groovy: > > /-- > > def ant = new AntBuilder() > > def webtest_home = "/opt/webtest" > > > > ant.taskdef(resource:'webtest.taskdef'){ > > classpath(){ > > pathelement(location:"$webtest_home/lib") > > fileset(dir:"$webtest_home/lib", includes:"**/*.jar") > > } > > } > > > > ant.webtest(name:'Test Google with Groovy, AntBuilder and WebTest'){ > > steps(){ > > invoke(url:'http://www.google.com') > > verifyTitle(text:'Google') > > setInputField(name:'q', value:'Groovy') > > clickButton(name:'btnG') > > verifyXPath(xpath:"//[EMAIL > > PROTECTED]'http://groovy.codehaus.org/']") > > } > > } > > \-- > > > > Any thoughts? > > _______________________________________________ > WebTest mailing list > [email protected] > http://lists.canoo.com/mailman/listinfo/webtest > _______________________________________________ WebTest mailing list [email protected] http://lists.canoo.com/mailman/listinfo/webtest

