[Webtest] accesing StepResults in a Groovy WebTest
Florent Blondeau
Florent Blondeau <fblondeau@pingwy.com>
Mon, 26 Nov 2007 14:36:53 +0100
Hi,
If I understand what you want, I can share a workaround I found when
using steps. Actually, I have some groovy code that call
webtest steps with ant, with a <groovy> step with some groovy code
(That's a bit weird, but it
was to test if this kind of thing works). I wanted to share variables
between my groovy code and
the groovy step, for example.
you can do something like this before calling your ant.testSpec :
ant.getAntProject().taskFinished = {buildEvent -> def task =
buildEvent.task
println "Task
finished ............ $task.taskType"
if
(task.taskType == 'testSpec'){
//that's fired when testSpec is finished, but you can
// do that for all your steps
//an example of what you can do :
// you get all the properties defined in your tests
// useful when you want to feed a database, for instance
task.dynamicProperties.each {key, value -> println key + " : " + value}
}
}
ant.getAntProject().taskStarted = { buildEvent -> def task =
buildEvent.task
println "Task
started ............ $task.taskType" }
If you want to get the results, I saw there was a method called
getResultBuilderListener() to get the listener which
contains the results. I didn't try but it could be a way to get that
with task.builderListener.previousResponse or something
like that
It's really possible that a much simpler way exists, but I'm pretty new
to webtest and I don't know all the possibilities. So
i don't claim that i hold the only truth ;-)
hope that helps
florent
Stefan Majer a écrit :
> Hi,
>
> i want to access the stepResults eg. duration etc. in a simple groovy
> webtest script like this:
>
> ant.testSpec(name:'simple Groovy Webtest'){
> config(config_map)
> steps(){
> invoke(url:'linkpage.html')
> verifyText(description:"Index", text:"index")
> }
> }
> }
>
> Is it possible to get these for every called step ?
>
> greetings
>
> Stefan Majer
>
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>
--
Pingwy
27, rue des arènes
49100 Angers