将代码覆盖率链接到版本控制 [英] Linking code coverage to version control

查看:84
本文介绍了将代码覆盖率链接到版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在提交更改之前,我想确保所有代码都已经过测试,可以通过代码覆盖率报告自动或手动进行测试,但是有很多遗留代码没有自动化测试,并且不会受到我的更改影响。

Before I commit a change, I'd like to be sure that all of it has been tested, either automatically or manually with a code coverage report, but there is lots of legacy code that doesn't have automated tests, and won't be affected by my changes.

是否有一种工具可以通过代码覆盖率报告交叉引用版本控制工具中的差异,并确保所有被改变了吗?

Is there a tool that can cross reference a diff from a version control tool with a code coverage report and make sure everything that has been changed has been run?

我意识到在代码覆盖的情况下,这可能会带来虚假的安全感,而且这样的事情更是如此,但我认为这将是值得尝试的。我使用git和PHP--我用XCache的代码coverager界面来浏览我已经运行的代码,这很有用,但如果在git commit或push time时可以自动运行,这将非常棒。

I realise that with code coverage, this may give a false sense of security, and with something like this, even more so, but I think it would be worth trying. I use git and PHP - I've used XCache's code coverager interface to browse what I have run, and it's useful, but it would be great if something could run automatically at git commit or push time.

推荐答案

有关的 GIT中 diff文件,有一个名为工具 diff-cover ,它可以检查覆盖范围。它需要Cobertura XML覆盖率报告,并与 git diff 的输出进行比较。然后,它报告差异中的行的覆盖率信息。

For git diffs, there is a tool named diff-cover, which can check coverage. It takes Cobertura XML coverage reports and compares with the output of git diff. It then reports coverage information for lines in the diff.

给定适当的覆盖率xml文件,您可以使用此命令检查变更的覆盖率与 master 分支:

Given the proper coverage xml file, you can use this command to check the coverage of your changes compared to the master branch:

$ diff-cover coverage.xml

与CI服务器集成也非常简单,只要它可以提供您需要比较的提交像Jenkins中的 $ GIT_PREVIOUS_COMMIT

It is also pretty simple to integrate with a CI server, as long as it can provide you with the commit you need to compare with, like $GIT_PREVIOUS_COMMIT in Jenkins.

这篇关于将代码覆盖率链接到版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆