Thanks - this works great!

Forgot that I could just embed groovy script into the ant test.

Thanks again,
Matt

On Tue, Jan 5, 2010 at 10:43 AM, Soula, William <[email protected]>wrote:

>  Ant's string comparison is very limited.  The <ifStep> can only evaluate
> if the property is the value "true" or not.  I believe the <condition>
> statement can compare a property to a word.  But I don't think either of
> these options would help you.  Whenever I want to use a "real" if statement
> I use a groovy step (used to use scriptStep with javascript but groovy is
> more powerful as it includes all of java).  Then I pass back a property set
> to true or false depending on what I want.  Below is my attempt at your flow
> and hopefully it will make my explanation more useful :)
>
> <tstamp>
>        <format property="month" pattern="MM"/>
> </tstamp>
> <groovy replaceProperties="true">
> if (${month}==1){
>        step.setWebtestProperty('test', 'true')
> }else {
> step.setWebtestProperty('test', 'false')
> }
> </groovy>
> <ifStep test="#{test}">
>        <then>
>                <!--Don't do test-->
>        </then>
>        <else>
>                <!--Test steps here-->
>        </else>
> </ifStep>
>
>
> ------------------------------
>
> Hi,
>
> Anyone know if it is possible to test date expressions within the <ifStep>
> of an Ant XML webtest?
>
> I have a test which, due to some circumstances outside of my control, will
> never work if the current date is the first month of the year. Rather than
> comment out this test during every January, I'd prefer to set a conditional
> to just not have the verify steps execute.
>
> I guess this is more a question of what it is possible and not possible to
> do within an Ant expression - I know I could pass in the current date in a
> property, but then I'm not sure if 1) it would be possible to parse this to
> test for "first month" or 2) if I could avoid passing the date in and
> instead examine a different property.
>
> Anyone try to do this before?
>
> Thanks
> Matt
>

Reply via email to