nunit2 Nant任务总是返回退出代码0(TeamCity 5.0)

时间:2009-12-24 11:43:30

标签: nunit nant teamcity

我无法为我的生活让我的nant构建文件在测试失败时终止并返回(从而阻止打包和工件步骤)

这是nant文件的单元部分:

<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>

无论我将haltonfailure,failonerror,failonfailureatend属性设置为true / false的组合,结果始终如下:

[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

请帮忙,因为我不想发布单元测试失败的二进制文件!!!

  

TeamCity 5.0 build 10669

     

AppMonApiTests.dll引用

     

nunit.framework.dll v2.5.3.9345

     

单元未安装在构建服务器或GAC上

     

使用Nant-0.85和Nantcontrib-0.85

谢谢, 乔纳森

1 个答案:

答案 0 :(得分:0)

这是我使用的目标,如果任何测试失败,它将终止:

<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>

首先,您可以尝试删除:

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

似乎这些不应该导致问题,但尝试让某些基本工作,然后你可以开始添加属性,看看是什么让它停止工作。

相关问题