开发者

Running all unit tests in nant, even if some fail!

开发者 https://www.devze.com 2023-02-21 17:57 出处:网络
I want my unit tests to run regardless of there being a failure. I want to know how many are failing not just the first one, so I don\'t go through the build, fail, fix and build again cycle. Also, it

I want my unit tests to run regardless of there being a failure. I want to know how many are failing not just the first one, so I don't go through the build, fail, fix and build again cycle. Also, it is the responsibility of an other team to fix some tests so I want to know our are ok.

So in Nant, I've added the following in a target for the unit tests, as failonerror is false it runs all the tests, but does not fail the build.

<nunit2 failonerror="false" haltonfailure="false"> 
    <test appconfig="tests.config">
        <assemblies basedir="${test.dir}">
           <include name="SomeTests.dll" />
        </assemblies>
    </test>
</nunit2>

At the end of the run, Nant reports

1 non-fatal error(s), 0 warning(s)

I want to check the non-fatal error count, if it is more than 0, I want to do something like this...

<fail message="Failures reported in unit tests."
      unless="report.errors == 0" />

except I don't know how to get the e开发者_StackOverflowrror count......does anyone know how?


Apart from the fact that dropping <nunit2> in favor of <exec> might be a good idea anyway, in Your special case the <exec> task can solve the problem:

<exec
  program="C:\dev\tools\NUnit\2.5.9\bin\net-2.0\nunit-console.exe"
  resultproperty="exec.nunit.result"
  failonerror="false">
  <arg file="C:\foo\bar.dll" />
</exec>
<if test="${int::parse(exec.nunit.result) != 0}">
  <!-- fail, print number of failures etc. -->
</if>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号