nunit2 Nant 任务始终返回退出代码 0 (TeamCity 5.0)

发布于 2024-08-16 04:40:27 字数 1002 浏览 2 评论 0原文

我只是无法让我的 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>

并且无论 true/false 的组合如何我将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

谢谢, 乔纳森

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恰似旧人归 2024-08-23 04:40:27

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

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

看起来那些不应该引起问题,但尝试让一些基本的工作正常,然后您可以开始添加属性以查看是什么导致它停止工作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文