简体   繁体   English

当单元测试用例失败时,Jenkins构建失败

[英]Jenkins build gets failed, when unit test cases are failed

Jenkins build gets failed, when unit test cases are failed, Here am using pipeline script in jenkins, Need to generate HTML report using mocha-awesome, I can get the HTML report only when all test cases are passed, Build fails if any functions failed in my testcases. Jenkins构建失败,当单元测试用例失败时,这里在jenkins中使用管道脚本,需要使用mocha-awesome生成HTML报告,我只能在所有测试用例通过后才能获取HTML报告,如果任何功能失败,构建就会失败在我的测试用例中。 Here you can see the screenshot 在这里您可以看到屏幕截图

The call to the unit test run returns with exit status 1 . 单元测试运行的调用以退出状态1返回。 What you can do is use the returnStatus option for the sh or bat step which will then not fail the build itself but leaves that up to you: 您可以做的是在shbat步骤中使用returnStatus选项,这将不会使构建本身失败,而是由您自己决定:

def exitStatus = sh returnStatus: true, script: 'unittests'

or: 要么:

def exitStatus = bat returnStatus: true, script: 'unittests.exe'

Having this you can selectively fail the build, ie if exitStatus == 1 then ignore as it signals a test fail, if it is anything but 0 or 1 then fail the build using the error step. 有了这个,您可以有选择地使构建失败,即,如果exitStatus == 1则忽略它,因为它表示测试失败;如果它不是01则使用error步骤使构建失败。

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

相关问题 Jenkins建立成功,但在单元测试中失败 - Jenkins build success but failed on Unit test 如果项目有测试用例,Jenkins 构建失败,Xcode - Jenkins build failed with Xcode if project have test cases 尽管单元测试失败,Jenkins Maven仍然可以获得成功 - Jenkins Maven build reports success despite failed unit test 如果任何测试用例使用 findText 插件失败,如何使 jenkins 构建失败 - how to fail the jenkins build if any test cases are failed using findText plugin ANT Jenkins单元测试 - 计算失败的测试 - ANT Jenkins unit test - count failed tests 通过詹金斯(Jenkins)运行机器人测试用例时,“失败:数据源不存在” - Got “failed: Data source does not exist” when running robot test cases via Jenkins 在测试MSTest失败后,在Jenkins中构建失败 - Build failure in Jenkins after failed test MSTest 如何在 jenkins 中重新运行失败的黄瓜 jvm 测试用例 - How rerun failed test cases of cucumber-jvm in jenkins 如何在 jenkins 中对失败的 Robot Framework 测试用例实现重新运行 - How to implement rerun on failed Robot Framework test cases in jenkins 我们可以在 Jenkins 中只执行失败的测试用例吗? - Can we execute only failed test cases in Jenkins?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM