Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code Coverage shows 0% for IntelliJ while running web app

I have a web server application that I am running inside IntelliJ. I want to run the server with code coverage, then execute an external test harness that will make requests, and see how much of the code is executed by those requests.

I can generate the correct code coverage when running unit tests from within the IDE, but when I run with Code Coverage on and execute with an external harness, I get all 0's for code coverage.

If I run the web app in the debugger instead, it triggers breakpoints as expected, so I know that code is being executed.

Please help!

like image 855
Kylar Avatar asked Dec 05 '13 21:12

Kylar


3 Answers

I had the same issue. Clicking Stop to end the process results in all 0% coverage, presumably due to the process not getting a chance to tidy up and generate results:

Stop Click this button to terminate the current process externally by means of the standard mechanisms.

Clicking Exit instead allows the coverage to generate properly:

Exit Click this button to terminate the current process gracefully using in-process internal mechanisms.

See here for more detail: https://www.jetbrains.com/idea/webhelp/test-runner-tab.html#

like image 124
RobEarl Avatar answered Nov 19 '22 02:11

RobEarl


This solution worked for me:

Go to IntelliJ Toolbar --> View --> ToolWindows --> Coverage. A Window wil appear on the right side. Here you can delete Classes from the list by selecting them and hit the red X on the bottom left corner.

screenshot of menu

like image 28
Maurits Avatar answered Nov 19 '22 02:11

Maurits


Got 0% coverage in ur IDEA?

Maybe you are viewing coverage per class. Try to switch it OFF using this little button:

enter image description here

Edit:

This button is supposed to show/switch coverage per test. It only appears, when you run your tests "with coverage" and it is located on toolbar of a Run panel (Alt + 4).

like image 1
teejay Avatar answered Nov 19 '22 02:11

teejay