Hi, I've been writing Groovy-only WebTests, which works great. However, stumbling on how to define and reuse a "macro" which consists of other webtest calls.
In this case, I want to call these two steps: invoke(url: "http://validator.w3.org/check?uri=${it}") verifyXPath(xpath: "id('form')/table/tbody/tr[1]/t...@class='valid']") and wrap them in a simple call such as validator("http://www.blah.com") I'd like to define these somewhere an reuse them. However, can't seem to get this to work. Approaches like this fail: class BlahTest extends WebtestCase { void testList() { def validator = { invoke(url: "http://validator.w3.org/check?uri=${it}&charset=%28detect+automatically%29&doctype=Inline&group=0") verifyXPath(xpath: "id('form')/table/tbody/tr[1]/t...@class='valid']") } webtest("List Pages") { validator("http://www.wordpress.com") } } } The only way that seems to work is if you embed the closure in the webtest itself: webtest("List Pages") { def validator = { invoke(url: "http://validator.w3.org/check?uri=${it}") verifyXPath(xpath: "id('form')/table/tbody/tr[1]/t...@class='valid']") } validator("http://www.wordpress.com") } but that sort of limits the usefulness of this. Any ideas? Thanks, G -- View this message in context: http://www.nabble.com/Groovy-equivalent-of-macro--tp24820735p24820735.html Sent from the WebTest mailing list archive at Nabble.com. _______________________________________________ WebTest mailing list [email protected] http://lists.canoo.com/mailman/listinfo/webtest

