简体   繁体   English

xUnit测试未通过时,Jenkins生成失败

[英]Fail Jenkins build when xUnit tests do not pass

I have Jenkins building my C# .NET Core api project. 我让詹金斯(Jenkins)构建我的C#.NET Core API项目。 I added some xUnit tests and included a powershell script inside of my Jenkins build with the "dotnet test" command to execute the tests. 我添加了一些xUnit测试,并在Jenkins构建中包含一个Powershell脚本,并使用“ dotnet test”命令来执行测试。 That all works well and the tests are run and i can see the output in the Jenkins console. 一切正常,测试正在运行,我可以在Jenkins控制台中看到输出。 The problem is that if i have failing tests nothing happens - jenkins goes merrily along and finished up the build process and reports it as a success. 问题是,如果我的测试失败,则什么也不会发生-詹金斯欣喜若狂,并完成了构建过程并将其报告为成功。

How can i get it to fail the build? 我如何才能使构建失败?

Is there a response from the 'dotnet test' command? 'dotnet test'命令是否有响应?

I know there are xUnit Jenkins plugins but they all seem to revolve around "display the results of xUnit tests". 我知道有xUnit Jenkins插件,但它们似乎都是围绕“显示xUnit测试的结果”而进行的。 Which is not really what i am after. 这不是我真正想要的。 I want to ACT on the results of the tests, not just see them in fancy html. 我想对测试结果采取行动,而不仅仅是在漂亮的html中看到它们。

You should check for the return code from dotnet test command. 您应该检查dotnet test命令的返回码。 It returns 0 if all tests were successful and 1 if any of the tests failed. 如果所有测试均成功,则返回0,如果任何测试失败,则返回1。 Unfortunately it's not documented but was confirmed in this issue 不幸的是,它没有记录,但在此问题中已得到确认

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM