【问题标题】:nunit2 Nant task always returns exit code 0 (TeamCity 5.0)nunit2 Nant 任务总是返回退出代码 0 (TeamCity 5.0)
【发布时间】:2010-03-29 15:00:13
【问题描述】:

我一辈子都无法让我的 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属性设置为哪种真/假组合,结果总是这样:

[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 内部版本 10669

AppMonApiTests.dll 参考

nunit.framework.dll v2.5.3.9345

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

使用 Nant-0.85 和 Nantcontrib-0.85

谢谢, 乔纳森

【问题讨论】:

    标签: nunit nant teamcity


    【解决方案1】:

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

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

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

    【讨论】:

    • 您好,删除这些属性没有任何区别。请记住,我没有使用 nunit-console,但我依靠 TeamCity 将 nunit2 任务替换为自定义任务。我没有使用任何 nunit TeamCity 插件或跑步者,所以究竟是什么在运行测试是一个谜...... doco 在这整个区域有点糟糕和令人沮丧
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-03
    相关资源
    最近更新 更多