Jason Manfield wrote:

I am calling nunit-console from within my nant and would like to check if the nunit test passed or failed by searching for the pattern 'failures="0" not-run="0"' in the output xml file generated by nunit-console. How do I search for patterns within a file with nant?

There is a grep in the NAntContrib package. See http://nantcontrib.sourceforge.net .

Personally, I wouldn't grep over the output, though. It's easier and more robust to use the NAnt xmlpeek task to pick the attributes out of the NUnit xml results file:

         <property name="res" value="test-results" />
         <xmlpeek file="${f}" property="tot" xpath="${res}/@total" />
         <xmlpeek file="${f}" property="tf" xpath="${res}/@failures" />
         <xmlpeek file="${f}" property="tn" xpath="${res}/@not-run" />
<echo file="${testsummary}" append="true" >${path::get-file-name(f)}: Total=${tot} Failures=${tf} Not-Run=${tn}</echo>

If NUnit ever changes their output format, or if they ever add similar attributes to the test-suite level, the grep approach can fail silently, while the xmlpeek won't.

Gary



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Nant-users mailing list
Nant-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to