AW: [Webtest] Ant Script to Fail when Test Fails

Marc Guillemot Marc Guillemot <mguillemot@yahoo.fr>
Thu, 04 Oct 2007 07:52:41 +0200


Hi Christoph,

I guess that you're scripts are well structured, meaning for instance
with a main build file and one build file per script. In this case, this
is a Ant "feature": properties set in a sub-build don't pop up.

You can use xml tasks (from
http://www.oopsconsultancy.com/software/xmltask/) to read the results in
------------
<path id="xmltask.classpath">
  <fileset dir="the/dir/to/xmltask.jar" includes="*.jar"/>
</path>
<taskdef name="xmltask"
classname="com.oopsconsultancy.xmltask.ant.XmlTask"
classpathref="xmltask.classpath"/>

<xmltask source="${webtests.resultpath}/${webtests.results}.xml">
  <copy path="count(/summary/testresult)" property="nbWebTests"/>
  <copy path="count(/summary/testresult[@successful = 'no'])"
property="nbWebTests.failed"/>
  <copy path="count(/summary/testresult[@successful = 'yes'])"
property="nbWebTests.successful"/>
</xmltask>
<echo message="WebTests results: ${nbWebTests.successful} successful,
${nbWebTests.failed} failed (total: ${nbWebTests})"/>
<fail>
  <condition>
    <not>
         <equals arg1="${nbWebTests.failed}" arg2="0"/>
    </not>
  </condition>
</fail>

------------

I'm thinking since some time to add something for this purpose directly
in WebTest. I've now opened the issue
http://webtest-community.canoo.com/jira/browse/WT-332

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


christoph.krammer@mvv.de wrote:
> Hello again,
> 
> I figured out that this should be possible with the "failureproperty" of the <config> tag. But I did not get how to use this property. When I use
> 
> <config
> 	...
> 	failureproperty="wt.test.failed" />
> 
> This property does not get set in case of failed tests.
> 
> Thanks for any help.
> 
> Regards,
>  Christoph
> 
> -----Ursprüngliche Nachricht-----
> Von: webtest-admin@lists.canoo.com [mailto:webtest-admin@lists.canoo.com] Im Auftrag von christoph.krammer@mvv.de
> Gesendet: Dienstag, 2. Oktober 2007 11:58
> An: webtest@lists.canoo.com
> Betreff: [Webtest] Ant Script to Fail when Test Fails
> 
> Hello everybody,
> 
> I want to do different actions in the Ant script when a test fails or is successful (deploy the application under test to a different application server). But to be able to do this, I have to decide whether a test was successful. But the Ant script states Build Successful even if tests fail. Is it possible to get a Build failed message, when a single test fails, but still to run all tests and generate the HTML output.
> 
> Thanks for any help.
> 
> Regards,
>  Christoph
> 
> ---
> Christoph Krammer
> 
> 24/7 IT-Services GmbH
> Luisenring 49
> 68159 Mannheim
> Germany
> 
> christoph.krammer@mvv.de
> www.24-7-it-services.de
> 
> 24/7 IT-SERVICES GmbH / Knooper Weg 75 / 24116 Kiel Handelsregister-Nr. HRB 7458, Amtsgericht Kiel
> Geschäftsführer: Dr. Dirk Bevers, Dr. Ulf Dunker _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>