Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading .coverage files from coverage.py into IntelliJ IDEA/PyCharm's coverage view

I have .coverage files indicating code coverage of my Django project produced by coverage.py:

coverage run --branch --source='.' manage.py test style

I can produce nice HTML reports with coverage html, but I'd really prefer to take advantage of IDEA's coverage view to indicate coverage in my project while I work on it.

I can't use IntelliJ's "Run with Coverage" command to generate the coverage data in the standard way. (Please take this for granted; I may ask a second question later about my reasons why.)

Is there any way I can import the .coverage files produces by coverage.py into IntelliJ IDEA?

like image 201
Jeremy Avatar asked Jan 31 '13 19:01

Jeremy


People also ask

How do I open a .coverage file in Pycharm?

View code coverage results Run the desired class with coverage, select suite to show, and open class in the editor. From the main menu, select Run | Show Code Coverage. Press Ctrl+Alt+F6 .

Why code coverage is not showing in IntelliJ?

If the plugin is disabled, the code coverage tabs will not be visible in the run/debug configuration dialogs. Try opening Settings > Build, Execution, Deployment > Coverage and check the "Activate Coverage View" checkbox. After that run another test with Coverage.


2 Answers

This is possible, at least as long as you run coverage in the root directory of your project.

First you need convert the .coverage file to coverage.xml by running coverage xml. Then it's just a matter of going to the Analyze menu, selecting "Show Code Coverage Data" and adding the XML file.

                                  

                      

like image 105
Jeremy Avatar answered Oct 23 '22 09:10

Jeremy


Thanks, and now with pycharm 2.7 you should go to Tools -> Show Code Coverage Data and add new File

like image 20
jesuspg Avatar answered Oct 23 '22 08:10

jesuspg