[Webtest] Groovy Step (XML/Groovy)

Pfau, Matthias Pfau, Matthias" <map@zuehlke.com
Sat, 26 Jul 2008 12:37:48 +0200


Hi Dierk,
this was the second time that I felt into this trap and tried various =
things without coming to an result. Probably because I'm still used to =
static languages and compilers that tell me: "Don't do that, wrong =
syntax!" ;-)

Anyhow, to avoid making this mistake again and to allow parameter =
injection for scripts, I tried to extend the GroovyStep to accept a =
Closure. This was the next trap. It took some time until I realized that =
AntBuilder uses Closures to create Nodes (which is pretty obvious...).

Is there any easy approach to parameterize a Step with a closure?
What I tried:
Extending AntBuilder to create specific Nodes ("groovy") with Closures =
as Attributes (Default: child nodes).

Unfortunately, this does not seem to be a valid approach because ant =
only allows a very restricted set of types for attributes:
	http://ant.apache.org/manual/develop.html#set-magic


It is time for holidays :)

Kind Regards
Matthias

-----Original Message-----
From: webtest-admin@lists.canoo.com =
[mailto:webtest-admin@lists.canoo.com] On Behalf Of Dierk K=F6nig
Sent: Freitag, 25. Juli 2008 21:57
To: webtest@lists.canoo.com; Pfau, Matthias
Subject: RE: [Webtest] Groovy Step (XML/Groovy)

Well, if you have a groovy step inside a Groovy webtest,
you have to provide the Groovy code as a String (or even
better in an external file, which I would recommend):

 		    groovy '''
 				print 'methods of step:'
 				print step.class.methods.name
 		    '''

cheers
Dierk

| -----Original Message-----
| From: webtest-admin@lists.canoo.com=20
| [mailto:webtest-admin@lists.canoo.com] On Behalf Of Pfau, Matthias
| Sent: Freitag, 25. Juli 2008 16:57
| To: webtest@lists.canoo.com
| Subject: [Webtest] Groovy Step (XML/Groovy)
|=20
| Hi,
| after a few hours I finally gave up. I simply do not=20
| understand why one testcase works as XML and not as=20
| Groovy-Code. The XML looks like:
| 	<?xml version=3D"1.0"?>
| =09
| 	<!DOCTYPE project SYSTEM "../dtd/Project.dtd">
| =09
| 	<project default=3D"test">
| 	 <target name=3D"test">
| =09
| 	  <webtest name=3D"check the groovy evaluation">
| 	    <groovy>
| 			print 'methods of step:'
| 			print step.class.methods.name   =20
| 	    </groovy>
| 	  </webtest>
| =09
| 	 </target>
| 	</project>
|=20
| The Groovy-Code looks like:
| 	import com.canoo.webtest.WebtestCase
| =09
| 	class SimpleTest extends WebtestCase {
| 	  void testWebtestOnGoogle() {
| 	    webtest("check Groovy evaluation") {
| 		    groovy {
| 				print 'methods of step:'
| 				print step.class.methods.name
| 		    }
| 	    }
| 	  }
| 	}
|=20
| Exception:=20
| =09
| testWebtestOnGoogle(SimpleTest)groovy.lang.MissingPropertyExce
ption: No such property: step for class: SimpleTest
|=20
| I tested against the latest build. Any ideas what went wrong?
|=20
| Kind Regards
| Matthias
| _______________________________________________
| WebTest mailing list
| WebTest@lists.canoo.com
| http://lists.canoo.com/mailman/listinfo/webtest
|=20
_______________________________________________
WebTest mailing list
WebTest@lists.canoo.com
http://lists.canoo.com/mailman/listinfo/webtest