Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distributed unit testing and code coverage in Python

My current project has a policy of 100% code coverage from its unit tests. Our continuous integration service will not allow developers to push code without 100% coverage.

As the project has grown, so has the time to run the full test suite. While developers typically run a subset of tests relevant to the code they are changing, they will usually do one final full run before submitting to CI, and the CI server itself also runs the full test suite.

Unit tests by their nature are highly parallelizable, as they are self-contained and stateless from test to test. They return only two pieces of information: pass/fail and the lines of code covered. A map/reduce solution seems like it would work very well.

Are there any Python testing frameworks that will run tests across a cluster of machines with code coverage and combine the results when finished?

like image 510
Joe Shaw Avatar asked Jan 20 '12 04:01

Joe Shaw


People also ask

What is code coverage in Python?

Coverage.py is one of the most popular code coverage tools for Python. It uses code analysis tools and tracing hooks provided in Python standard library to measure coverage. It runs on major versions of CPython, PyPy, Jython and IronPython. You can use Coverage.py with both unittest and Pytest.

What is unit testing and code coverage?

Unit tests help to ensure functionality and provide a means of verification for refactoring efforts. Code coverage is a measurement of the amount of code that is run by unit tests - either lines, branches, or methods.

What is the difference between code coverage and test coverage?

While code coverage helps you verify if each code in the software application is being executed by existing tests or not, test coverage indicates whether those tests are covering all the functional requirements of the application or not.


1 Answers

I don't know of any testing frameworks that will run tests distributed off a group of machines, but nose has support for parallelizing tests on the same machine using multiprocessing.

At minimum that might be a good place to start to create a distributed testing framework

like image 174
cnelson Avatar answered Oct 14 '22 15:10

cnelson