简体   繁体   English

如果测试失败,使Android jenkins构建失败

[英]Make Android jenkins build fail if tests fail

I have seen several post regarding making a build in Jenkins fail if the unit test execution fail (eg this one ). 我所看到的关于使得如果单元测试执行失败(例如,这詹金斯构建失败几个后一个 )。 It turns out that by default Jenkins reports builds with failing tests as unstable and some people do not like that. 事实证明,默认情况下Jenkins报告使用失败测试的构建unstable ,有些人不喜欢这样。 This, however, will be perfectly fine for me. 然而,这对我来说完全没问题。 I just want to be able to easily differentiate builds with passing tests from such with failing tests. 我只是希望能够通过测试失败来轻松区分构建和测试。

And here is the catch: I am developing for Android so my build is configured following this page . 这里有一个问题: 我正在为Android开发,所以我的构建是在此页面之后配置的。 Basically the tests are run with the following command: 基本上,测试使用以下命令运行:

ant all clean emma debug install test

As result coverage report is generated and published in Jenkins. 结果覆盖率报告在Jenkins中生成并发布。

All posts I have read about configuring the Jenkins result according to tests results were dealing with ant task manipulation. 我读过的关于根据测试结果配置Jenkins结果的所有帖子都涉及到ant任务操作。 However, if we look at the android build.xml the Android tests are run with adb command: adb shell am instrument ... . 但是,如果我们查看android build.xml ,则使用adb命令运行Android测试: adb shell am instrument ... I don't know how to configure this command to print the tests results. 我不知道如何配置此命令来打印测试结果。 It can be configured to print the coverage report. 它可以配置为打印覆盖率报告。 I have already done that, but was never able to make the build fail according to the coverage report. 我已经这样做了,但根据覆盖率报告,从未能够使构建失败。

I hope somebody else also faced the same problem and managed to solve it. 我希望其他人也遇到同样的问题并设法解决它。 Any guidance will be most appreciated. 任何指导将非常感谢。

This is possible, configure the server using the following documentation: 这是可能的,使用以下文档配置服务器:

https://wiki.jenkins-ci.org/display/JENKINS/Android+Emulator+Plugin https://wiki.jenkins-ci.org/display/JENKINS/Android+Emulator+Plugin

See "Parsing monkey output" in the link. 请参阅链接中的“解析猴子输出”。

Addition, Jenkins can test instrumentation, below have a link of a good place to start in the learning of instrumentation: 另外,Jenkins可以测试仪器,下面有一个开始学习仪器的好地方的链接:

http://developer.android.com/resources/tutorials/testing/helloandroid_test.html http://developer.android.com/resources/tutorials/testing/helloandroid_test.html

I hope it is useful. 我希望它有用。

我的项目jenkins的屏幕截图

Consider using 'the-missing-android-xml-junit-test-runner' - the idea being to produce jUnit reports that Jenkins understands. 考虑使用'the-missing-android-xml-junit-test-runner' - 想要生成Jenkins理解的jUnit报告。 Disclaimer: I do have no personal experience with adb . 免责声明:我没有adb的个人经验。 However, I do know from experience that Jenkins deals with properly generated jUnit reports very gracefully. 但是,我从经验中知道Jenkins非常优雅地处理正确生成的jUnit报告。

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

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