Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Code coverage in IntelliJ 2017

I have written some Test methods using Junit and mockito. My tests run fine. However, I am not able to see code coverage.

enter image description here

No matter which option I click on, nothing is shown in code coverage. I clicked on EDIT to fix configuration seetings displayed in middle of code coverage window on right. This is what I get :

enter image description here

enter image description here

What should I do to get code coverage results ?

This is my folder structure :

enter image description here

like image 926
Number945 Avatar asked Apr 25 '17 10:04

Number945


People also ask

Why code coverage is not showing in IntelliJ?

From the main menu, select Run | Show Coverage Data ( Ctrl+Alt+F6 ). In the Choose Coverage Suite to Display dialog, select the checkboxes next to the necessary suites, and click Show selected. IntelliJ IDEA opens the coverage results for the selected test suites.

How do I turn off IntelliJ coverage?

To disable code coverage highlighting In the IDEA IDE, on the Analyze menu, click Show Code Coverage Data, or use the Ctrl+Alt+F6 keyboard shortcut. In the Code Coverage Suites dialog, choose No coverage.

How do I enable branch coverage in IntelliJ?

In IntelliJ to add "branch coverage" to the coverage window, you can go to Run/EditConfiguration then proceed to Modify options/coverage setting and enable use tracing.


2 Answers

To see coverage for production code change the pattern to com.cdk.dmg.asset.

You need to Enable coverage in test folders if you want see coverage in tests (this option is disabled on your screenshot and the pattern is set to record data for tests only, hence no results).

like image 127
CrazyCoder Avatar answered Nov 04 '22 11:11

CrazyCoder


Make sure you have the Coverage plugin enabled! (yes, it's named literally just "Coverage") Enabling it did it for me.

You don't need to download it from Marketplace, the plugin comes bundled with IntelliJ Idea.

It's my understanding that it should be enabled by default ..but for some reason that wasn't the case for me, so it might as well not be the case for you either.

like image 27
Licanueto Avatar answered Nov 04 '22 11:11

Licanueto