[Webtest] Step failure and ifStep
Paul King
webtest@lists.canoo.com
Mon, 16 Jan 2006 21:15:58 +1000
You could try something like:
<target name="main" depends="checkLink,nonLinkTests,linkTests"/>
<target name="checkLink">
<webtest name="various fail tests">
<config ...
failureProperty="checkLinkFailure"
haltOnFailure="false"/>
<steps>
<invoke url="..."/>
<verifyText text="link to check">
</steps>
</webtest>
</target>
<target name="nonLinkTests" if="checkLinkFailure">
<!-- non link tests go here -->
</target>
<target name="linkTests" unless="checkLinkFailure">
<!-- link tests go here -->
</target>
KLOPP Gerald wrote:
> Hi,
>
> I've already posted a message untitled 'click link only if it exists'
> but I think the problem is more general.
> Sometimes I want to execute a step and, if it fails, execute specific
> other steps
>
> For example :
> <verifyText text="text to check">
> <ifStep test="haltonfail.property">
> <!-- Steps to execute if verifyText fails -->
> </ifStep>
>
> Setting the 'haltonerror' and 'haltonfail' properties of the 'config'
> task to false doesn't resolve the problem because the next step is never
> executed.
> In the example, if the verifyText fails, the ifStep is never reached.
>
> - One possible solution could be to refine the 'haltonfail' property and
> to replace it with one like the following :
> property 'onfail' with the values :
> - 'nextWebTest' : processes the next web test if one step fails,
> equivalent to haltonfail='false',
> - 'nextStep' : processes the next step if one step fails
> - 'halt' : stops the build, equivalent to haltonfail='true'
>
> - One other solution could be to modify the verifyXXX steps and have the
> possibility to store the result of the step in a property instead of halting
> Example :
> <verifyText failProperty="fail"
> text="text to check">
> <ifStep test="fail">
> <!-- Steps to execute if verifyText fails -->
> </ifStep>
>
> - One other solution could be to modify the ifStep and have the
> possibility to specify the test inside the target.
> The test is true if the task executed doesn't fail
> Example :
> <ifStep>
> <test>
> <verifyText text="text to check">
> </test>
> <!-- Steps to execute if verifyText fails -->
> </ifStep>
>
>
> What do you think?