问题描述
我使用hudson CI来管理一个直接的java web项目,使用ant来构建。
我想要求单元测试覆盖率不会比
是否有一个hudson插件可以这样工作?
p>编辑:我目前正在使用Emma,但愿意切换到另一个保险应用程序。
澄清,我已经看到了一些Hudson插件的阈值,但这不是我的后面。例如,我想要的是,如果Build#12的覆盖率为46%,而有人在45%的覆盖率下签入Build#13,则构建会中断。
我想这样做的原因是,我有一个低测试覆盖率的代码库。我们没有时间回溯,追溯地编写单元测试,但我想确保覆盖率持续改善。
更新:Dan指出一个边缘情况与我的计划,一定会是一个问题。我想我需要重新思考这是否一个好主意。
是的。您使用哪个覆盖工具?
Hudson的Cobertura插件绝对支持这一点。在项目配置屏幕上,您可以指定阈值。
或者,您可以使用cobertura检查任务使Ant失败构建(而不是Hudson) p>
编辑:我不确定您能够做的正是您要求什么。即使你可以,它可以证明有问题。例如,假设您的平均覆盖率为75%,但对于一个类,您的覆盖率为80%。如果你删除那个80%的类和它的所有测试,你减少了总覆盖百分比,即使没有其他代码比以前测试任何测试。
I am using hudson CI to manage a straight java web project, using ant to build.
I would like to mandate that the unit test coverage never be worse than the previous build, thereby making sure any new code is always tested, or at least the coverage is continually improving.
Is there a hudson plugin that works this way?
Edit: I am currently using Emma, but would be willing to switch to another coverage app.
Also, as a clarification, I've seen the thresholds in some Hudson plugins, but that's not exactly what I'm after. For example what I'd like is that if coverage for Build #12 was 46% overall, and someone checked in Build #13 with 45% coverage, the build would break.
The reason I want to do this, is that I have a codebase with low test coverage. We don't have time to go back and retroactively write unit tests, but I'd like to make sure that the coverage keeps getting better.
UPDATE: Dan pointed out an edge case with my plan that will definitely be a problem. I think I need to rethink whether this is even a good idea.
Yes. Which coverage tool are you using?
The Cobertura plugin for Hudson definitely supports this. On the project configuration screen you can specify thresholds.
Alternatively, you can make Ant fail the build (rather than Hudson), by using the cobertura-check task.
EDIT: I'm not sure you can do precisely what you are asking for. Even if you could, it could prove problematic. For example, assume you have an average coverage of 75% but for one class you have coverage of 80%. If you remove that 80% class and all of its tests, you reduce the overall coverage percentage even though none of the other code is any less tested than previously.
这篇关于我的构建可以规定我的代码覆盖率不会变得更糟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!