Linking Version Control Code

Before making any change, I would like to make sure that all of this was checked automatically or manually using the code coverage report, but there is a lot of outdated code that does not have automatic tests, and my changes will not be affected.

Is there a tool that can cross-reference diff from a version control tool to a code coverage report and make sure everything that was changed was running?

I understand that with code coverage this can give a false sense of security and something like that, all the more, but I think it's worth a try. I use git and PHP - I used the XCache shell interface to see what I ran, and this is useful, but it would be great if something could automatically start in git commit or push time.

+8
git version-control php testing code-coverage
source share
2 answers

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

Given the correct contents of the xml file, you can use this command to check the scope of your changes compared to the master branch:

 $ diff-cover coverage.xml 

It is also quite easy to integrate with the CI server if it can provide you with a commit that you need to compare with, for example, $GIT_PREVIOUS_COMMIT in Jenkins.

+3
source share

You can set up a continuous integration build server (there are many great, free build servers ). At one of the stages of construction, code coverage will be performed. You can configure it to ignore obsolete code and calculate coverage only for non-obsolete code. Then you set it to fail assembly if coverage <xx%. Or even crash if coverage% is reduced from the previous build.

+3
source share

All Articles