I tried to do that and also failed. I kept investigating and I can't get the
datadriven task working with groovy code.
It's working for me if I do it in an xml, but if I try it in groovy it
fails.
I know that webtest() is a method in WebtestCase class :
-------------------------------------------------------------
* void webtest(String name, Closure yield)
{
createAntBuilder()
ant.webtest(name: name)
{
config()
yield.delegate = ant
yield()
}*
}
----------------------------------------------------------------
but dataDriven is an ant task.
https://svn.canoo.com/trunk/webtest/src/main/java/com/canoo/ant/task/PropertyTableTask.java
I am not sure if this is the reason, but could it be that due to the fact
that the dataDriven task is called befored the webtest method is called, the
AntBuilder method is not called. So there is no way to associate the
dataDriven task with an Ant task. ????
Does anyone has an example of DataDriven Testing using groovy that works? It
would be really help full.
*
---------------------------TEST CODE
---------------------------------------------
import com.canoo.webtest.WebtestCase
import junit.framework.Test
public class SeoHomepageAllCountriesTest extends WebtestCase {
public void testSeoStructure() {
dataDriven(tableContainer: "metatagshomepage.xls") {
webtest("Testing Title - Meta Description -
MetaKeyword"){
config haltonerror: "false", haltonfailure: "false"
echo message:"language_id",
{}
}
}
}
-------------------------------------------------------------------------------------
----------------------------ERROR STACKTRACE
-------------------------------------------
Test set: SeoHomepageAllCountriesTest
---------------------------------------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.056 sec
<<< FAILURE!
testSeoStructure(SeoHomepageAllCountriesTest) Time elapsed: 0.003 sec <<<
ERROR!
groovy.lang.MissingMethodException: No signature of method:
SeoHomepageAllCountriesTest.dataDriven() is applicable for argument types:
(java.util.LinkedHashMap,
SeoHomepageAllCountriesTest$_testSeoStructure_closure1) values:
[[tableContainer:metatagshomepage.xls],
seohomepageallcountriestest$_testseostructure_closu...@188f506]
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
at
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:78)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:155)
at
SeoHomepageAllCountriesTest.testSeoStructure(SeoHomepageAllCountriesTest.groovy:11)
----------------------------------------------------------------------------------------------------------------------------------
*Thanks,
Hernan
2009/7/21 Marc Guillemot <[email protected]>
> Hi,
>
> try to change the line:
> dataDriven tableContainer: "metatagshomepage.xls" {
>
> to
> dataDriven(tableContainer: "metatagshomepage.xls") {
>
> Groovy doesn't always need parentheses but sometimes it helps ;-)
>
> Cheers,
> Marc.
>
> Hernan Castagnola wrote:
>
>> Thanks Marc for your help!
>>
>>
>> About the stacktrace this is what I am getting:
>>
>>
>> -------------------------------------------------------------------------------
>> Test set: SeoHomepageAllCountriesTest
>>
>> -------------------------------------------------------------------------------
>> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.016 sec
>> <<< FAILURE!
>> testSeoStructure(SeoHomepageAllCountriesTest) Time elapsed: 0.006 sec
>> <<< ERROR!
>> groovy.lang.MissingMethodException: No signature of method:
>> SeoHomepageAllCountriesTest.metatagshomepage.xls() is applicable for
>> argument types: (SeoHomepageAllCountriesTest$_testSeoStructure_closure1)
>> values: [seohomepageallcountriestest$_testseostructure_closu...@836869]
>> at
>> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
>> at
>> org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:78)
>> at
>> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
>> at
>> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
>> at
>> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
>> at
>> SeoHomepageAllCountriesTest.testSeoStructure(SeoHomepageAllCountriesTest.groovy:8)
>>
>>
>> And this is the code
>>
>>
>> public void testSeoStructure() {
>> dataDriven tableContainer: "metatagshomepage.xls" {
>> webtest("Testing Title - Meta Description - MetaKeyword"){
>> config haltonerror: "false", haltonfailure: "false"
>> echo message:"$language_id",
>> {}
>>
>> }
>> }
>> }
>>
>>
>> About the Wiki. I tried to use the Wiki you mentioned and sorry but that
>> wiki it's really hard to use.
>> I really don't have too much time, but on my free time I am going to try
>> to help you on this point (Wiki). I was thinking if we can move the content
>> you have on the canoo wiki, to a google wiki, as Tellerium does :
>> http://code.google.com/p/aost/wiki/Tutorial.
>> In my opinion it will be easier to read, search and maintain.Also I think
>> the project will have more activity over there.
>> What do you think about this point?
>>
>> Thanks!
>>
>> Hernan
>>
>>
>> 2009/7/11 Marc Guillemot <[email protected] <mailto:[email protected]
>> >>
>>
>>
>> Hi,
>>
>> can you provide the stacktrace of your failure?
>>
>> All user contributions are welcome. WebTest already has a wiki... but
>> not very active:
>> http://webtest-community.canoo.com/wiki/space/start
>>
>> Cheers,
>> Marc.
>> --
>> Web: http://www.efficient-webtesting.com
>> Blog: http://mguillem.wordpress.com
>>
>> Hernan Castagnola wrote:
>> > Hi everybody,
>> >
>> > I am trying to use the ant datadriven task in a
>> > groovy test but I can't succeed. What I am doing is:
>> >
>> > void testBlah() {
>> > dataDriven tableContainer: "blah.xls" {
>> > webtest("Check Blah")
>> > {
>> > config browser: "ff3"
>> > enableJavaScript enable:"false"
>> > invoke url: "http://\${Country_url}" ,
>> description: "Go
>> > to \${Country)"
>> > }
>> > }
>> >
>> > } <mailto:[email protected]
>> <mailto:[email protected]>>
>> >
>> > But I am getting the following message:
>> >
>> > Content is not allowed in prolog.
>> >
>> >
>> > Does anyone has an example of how to do DataDriven Testing in a
>> groovy test?
>> >
>> > Can we create a twiki with usefull examples for the webtest ? I
>> can help
>> > with that. And it will be really helpful for the users. One of
>> the point
>> > I am looking when a search for a tool is the time spent learning the
>> > basis and community support to solve issues. A wiki with examples I
>> > think is really useful. What do you think?
>> >
>> > Thanks,
>> >
>> > Hernan
>> >
>>
>> _______________________________________________
>> WebTest mailing list
>> [email protected] <mailto:[email protected]>
>> http://lists.canoo.com/mailman/listinfo/webtest
>>
>>
>>
> _______________________________________________
> WebTest mailing list
> [email protected]
> http://lists.canoo.com/mailman/listinfo/webtest
>