Hi,
dataDriven is not a method but an Ant task therefore it has to be
resolved against the AntBuilder:
getAnt().dataDriven(....) {
}
Cheers,
Marc.
Hernan Castagnola a écrit :
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] <mailto:[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.
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest