13

I know Eclipse + PyDev has an option Run As => 3 Python Coverage. But all it reports is:

Ran 6 tests in 0.001s

OK

And it says nothing about code coverage. How to get a code coverage report in Pydev?

3 Answers 3

14
  • Run a file with "Python Coverage"
  • Window > Show View > Code Coverage Results View
  • Select the directory in which the executed file is
  • Double-click on the executed file in the file list
  • Statistics are now at the right, not executed lines are marked red in the code view

Actually this is a really nice feature, didn't know about it before :)

2
  • Did not work for me, when I select the directory with the python file it's not listed in the coverage view.
    – Zitrax
    Feb 4, 2011 at 22:10
  • You might as well have to pip3 install pytest-cov to make this work . Jan 4, 2021 at 5:07
8

Note that in pydev 2.0, the coverage support changed, now, you should first open the coverage view and select the 'enable code coverage for new launches'... after that, any launch you do (regular or unit-test) will have coverage information being gathered (and the results inspection also became a bit more intuitive).

0

See if this helps http://www.machine-envy.com/blog/2006/07/29/automated-python-testing-with-nose-and-eclipse/

It uses nosetests with the –with-coverage option.

1
  • it seems that everyone in SO supports nose ;)
    – Jader Dias
    Feb 14, 2010 at 21:20

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.