Hi,

extending AntBuilder to allow the groovy step (or with an other name
like "groovyInWebtest") to accept a closure as "stuff to be executed" is
exactly what I'd like to see. But I haven't had time to implement it... ;-(

Cheers,
Marc.
-- 
Blog: http://mguillem.wordpress.com


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

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to