Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I ensure good test-coverage of my big Python proejct

I have a very large python project with a very large test suite. Recently we have decided to quantify the quality of our test-coverage.

I'm looking for a tool to automate the test coverage report generation. Ideally I'd like to have attractive, easy to read reports but I'd settle for less attractive reports if I could make it work quickly.

I've tried Nose, which is not good enough: It is incompatible with distribute / setuptools' namespace package feature. Unfortunately nose coverage will never work for us since we make abundant use of this feature. That's a real shame because Nose seems to work really nicely in Hudson (mostly)

As an alternative, I've heard that there's a way to do a Python coverage analysis in Eclipse, but I've not quite locked-down the perfect technique.

Any suggestions welcome!

FYI we use Python 2.4.4 on Windows XP 32bit

like image 701
Salim Fadhley Avatar asked Jun 25 '10 09:06

Salim Fadhley


People also ask

How do you ensure you have enough of test coverage?

Make appropriate test cases that cover the maximum test scenarios required based on the current release. Perform testing before the release so that the focus is provided to cover more scenarios in less time on a scheduled basis. Ensure to cover pending items of release while having a new release.

Is it possible to achieve 100% test coverage How would you ensure it?

Yes, 100% Test coverage is possible. It always varies from application to application, the major factors that ensures test coverage are size of the application, complexity of the code and project bandwidth. Small the size of the application and more the coverage is achievable.

How do I run a Python project coverage?

Open the desired file in the Project tool window and choose Run <name> with Coverage from the context menu. You can also select a directory with test files and choose the corresponding command from the context menu to run several tests with coverage.


1 Answers

Have you tried using coverage.py? It underlies "nose coverage", but can be run perfectly well outside of nose if you need to.

If you run your tests with (hypothetically) python run_my_tests.py, then you can measure coverage with coverage run run_my_tests.py, then get HTML reports with coverage html.

From your description, I'm not sure what problem you had with nose, especially whether it was a nose issue, or a coverage.py issue. Provide some more details, and I'm sure we can work through them.

like image 86
Ned Batchelder Avatar answered Oct 18 '22 02:10

Ned Batchelder