Coveralls with Github and Travis
The other day when I was making a PR to a Github project I got a comment like this:
Coverage decreased (-0.87%) when pulling f285fe0 on Nyholm:patch-1 into 5506244 on some-project:master. </blockquote>
This was an automated message from Coveralls.io. It is a tool made for Ruby to keep track of your test code coverage. I think it is a nice way of telling the pull request author: "You need to add tests".
If you want to install Coveralls to your PHP project there is a few step you need to do. But first of, make sure you use Github and Travis.
Step 1 - Register your project at Coveralls
Go to Coveralls.io and login with your Github account. You will get a list of your repositories (just like in Travis) and then select those you want to use with Coveralls.Step 2 - Tell Travis to tell Coveralls
You need to tell Travis to send data to Coveralls. This is done with the satooshi/php-coveralls library. This is a example .travis.yml file I start by installing satooshi/php-coveralls. Then I make sure I got a folder to store the reports. I run PHPUnit and make sure it is generating some the reports. At last we run coveralls (but not on HHVM). Easy as pie =)Step 3 - Optional
You may want to update you phpunit.xml.dist. Do this to make sure the proper files and directories are used when calculating the code coverage. See this example: That is all you need to do. Happy testing!
Leave a Comment