views:

208

answers:

1

Hello,

I just cannot for the life of me get my nant build file to terminate upon a test failure and return (thus preventing the packaging and artifact step from running)

This is the unit part of the nant file:

<target name="unittest" depends="build">
  <nunit2 verbose="true" haltonfailure="false" failonerror="true" failonfailureatend="true">
   <formatter type="Xml" />
   <test assemblyname="Code\AppMonApiTests\bin\Release\AppMonApiTests.dll" />
  </nunit2>
</target>

And regardless what combination of true/false i set the haltonfailure, failonerror, failonfailureatend properties to, the result is always this:

[11:15:09]: Some tests has failed in C:\Build\TeamCity\buildAgent\work\ba5b94566a814a34\Code\AppMonApiTests\bin\Release\AppMonApiTests.dll, tests run terminated. 
[11:15:09]: NUnit Launcher exited with code: 1
[11:15:09]: Exit code 0 will be returned.1

Please help as i don't want to be publishing binarys where the unit tests have failed!!!

TeamCity 5.0 build 10669

AppMonApiTests.dll references

nunit.framework.dll v2.5.3.9345

unit isn't installed on the build server or GAC'd

Using Nant-0.85 and Nantcontrib-0.85

Thanks, Jonathan

A: 

This is the target I use and it terminates if any tests fail:

<target name="test" depends="compile_tests,copy_dependencies">
    <mkdir dir="${testlogdir}"/>

    <echo message="Please make sure that nunit-console is in your path."/>
    <echo message="This file can be found in the NUnit bin directory."/>

    <nunit2 verbose="true">
        <formatter type="Xml" usefile="true" outputdir="${testlogdir}" extension=".xml"/>
        <formatter type="Plain" usefile="true" outputdir="${testlogdir}" extension=".txt"/>
        <test assemblyname="${build_classdir}\${namespace_file}.Test.dll"/>
    </nunit2>

</target>

So for starters, you could try removing:

haltonfailure="false" failonerror="true" failonfailureatend="true"

It seems like those shouldn't be causing a problem, but try to get something basic working, and then you can start adding in attributes to see what makes it stop working.

dcp
Hello, removing those properties has made no difference. Remember i'm not using nunit-console, but I am relying on TeamCity to replace the nunit2 task with it's custom one. I'm not using any nunit TeamCity plugins or runners, so what exactly is running the tests is a mystery.... the doco is a bit poor and frustrating around this whole area
Jonathan