One of my most popular GitHub Open Source projects is premailer. It's a python library for combining HTML and CSS into HTML with all its CSS inlined into tags. This is a useful and necessary technique when sending HTML emails because you can't send those with an external CSS file (or even a CSS style tag in many cases).
The project has had 23 contributors so far and as always people come in get some itch they have scratched and then leave. I really try to get good test coverage and when people come with code I almost always require that it should come with tests too.
But sometimes you miss things. Also, this project was born as a weekend hack that slowly morphed into an actual package and its own repository and I bet there was code from that day that was never fully test covered.
So today I combed through the code and plugged all the holes where there wasn't test coverage.
Also, I set up Coveralls (project page) which is an awesome service that hooks itself up with Travis CI so that on every build and every Pull Request, the tests are run with
nosetests and that output is reported to Coveralls.
The relevant changes you need to do are:
1) You need to go to coveralls.io (sign in with your GitHub account) and add the repo.
2) Edit your
.travis.yml file to contain the following:
before_install: - pip install coverage ... after_success: - pip install coveralls - coveralls
And you need to execute your tests so that coverage is calculated (the coverage module stores everything in a
.coverage file which
coveralls analyzes and sends). So in my case I change to this:
script: - nosetests premailer --with-cover --cover-erase --cover-package=premailer
3) You must also give
coveralls some clues. So it reports on only the relevant files. Here's what mine looked like:
[run] source = premailer [report] omit = premailer/test*
Now, I get to have a cute "coverage: 100%" badge in the README and when people post pull requests Coveralls will post a comment to reflect how the pull request changes the test coverage.
I am so grateful for all these wonderful tools. And it's all free too!