Clearing coverage highlighting in Eclipse
Asked Answered
M

10

676

After running coverage reports in Eclipse (using cobertura or an EMMA plugin), my source code files get highlighted in green, red and yellow depending on which lines of code were covered by tests.

How can I clear this highlighting after I'm done?

Masters answered 24/5, 2011 at 15:3 Comment(0)
O
1144

Click the "Remove all Sessions" button in the toolbar of the "Coverage" view.

enter image description here

Obeng answered 25/5, 2011 at 8:12 Comment(15)
I can see "Coverage Session View" under eCobertura. Is that the view I am supposed to use? But I don't see "Remove all Sessions" button. Where can I find it?Snowbird
No that view comes from another plug-in. You should use the view "Coverage".Obeng
Is there more than one Cobertura eclipse plugin? In Eclipse Juno, with eCobertura 0.9.8.201007202152, the "Coverage session view" is the only coverage view I have, and there is no such button in that view.Carlitacarlo
Same as James A Wilson. I can only find the eCobertura "Coverage Session View" and it only has one button, a button that opens a coverage session. Is eCobertura not updated for Juno, perhaps?Skippet
See this for EclEmma plugin in eclipse eclemma.org/userdoc/coverageview.htmlEpidiascope
Helpful Note: the "Remove all Sessons" button is the black double X -- like the one you click to close all consolesBisset
This answer is only valid for EclEmma. For eCorbertura, as soon as you edit the file the highlighting goes away. That's the only way I know how to remove the highlighting using eCorbertura.Giuseppe
The color of these two buttons is ridiculous. I was sure they were grayed out.Stairs
Remove Session is the little grey X button. it seems disabled but it's not in the coverage view when you see your test session. Also, in windows preferences, you can disable the default coverage automatically.Crybaby
AFAICT, this completely deletes the information. You have to rerun the test to get it back. Is there a way to just hide it?Rummel
If the Coverage view is not currently visible, it can be opened through Window -> Show View -> Other... and typing in Coverage and then clicking Java/Coverage. As mentioned by others, the Remove All Sessions button seem unpressable due to its color, but it can be pressed anyways.Phatic
I had to open the Coverage View from Window -> Show View -> Other -> search for Coverage, and then press the "Remove all Sessions"-button.Sivan
Thank you so much for this answer! This is super annoying when you first run across it.Inoffensive
I actually mapped a key to it. There you need to know the full name indeed as Pieter12345 mentions: Remove All Sessions.Hankering
as in 2023-R12 is hidden really good, cant find it.Dunsinane
H
75

On 4.2 eclipse it seems to be impossible to remove the eCobertura highlights. Sadly eCobertura plugins seems to be not maintained anymore. However if you start writing into the class, its gone. So type a space, and then undo, and its gone.

Harbaugh answered 19/10, 2012 at 9:48 Comment(4)
Eclemma is maintained, but does not work properly with some unit testing framework features of Mockito and Powermock. So basicly it has problems with complicated classloading and code weaving (see for example code.google.com/p/powermock/issues/detail?id=402). Ecoberture works with such stuff as well (since it uses offline instrumentation), but its not (at least seems to be not) maintained anymore.Dygert
@Shervin Clover is really good, but of course you have to pay for it. For personal development, I think EclEmma is sufficient.Emmieemmit
For Clover you can hide the colors in the java editor by going to "Clover | Coverage Explorer" -> Coverage in Editors > Show None. Hides all red/green coverage areas in open Java editors.Creight
Modifying a Java file removes the coverage highlighting, but only for that file. Other relevant java files continue to show highlighting.Sexism
B
66

For people who are not able to find the coverage view , follow these steps :

Go to Windows Menu bar > Show View > Other > Type coverage and open it.

enter image description here

Click on Coverage.

To clear highlightings, click on X or XX icon as per convenience.

enter image description here

Bestir answered 20/9, 2019 at 2:16 Comment(1)
Excellent Thank you.Kerb
L
18

I found a workaround over on GitHub: https://github.com/jmhofer/eCobertura/issues/8

For those who don't want to click the link, here's the text of the comment:

Good workaround: Create a run configuration with a filter, that excludes everything ("*") and let it run just a single test. Name it "Undo coverage".

I did this and it worked quite well in Eclipse Juno.

Credit for this goes to UsulSK.

Lynnett answered 29/11, 2012 at 17:33 Comment(0)
J
10

If you remove the coverage session, also the coverage coloring will disappear. For this, hit Remove Session or Remove All Sessions in the Coverage view's toolbar.

http://eclemma.org/faq.html

Julenejulep answered 29/10, 2015 at 9:43 Comment(0)
T
8

For those using Cobertura and only have the Coverage Session View like I do,just try closing Eclipse and starting it up again. This got rid of the highlighting for me.

Toll answered 15/11, 2012 at 0:41 Comment(2)
Seems a bit crude. Isn't there any other way?Sextuplicate
Restarting is not feasible.. if you are doing lot of testing with code coverage.Histrionism
H
7

Added shortcut Ctrl+Shift+X C to Keybindings (Window -> Preferences -> filter for Keys) when 'Editing Java Source' for 'Remove Active Session'.

Hadwin answered 2/10, 2014 at 15:55 Comment(0)
A
3

If you would like to remove active session/project/folder then you can follow

Click the "Remove Active Session" button in the toolbar of the "Coverage" view.

Aquilegia answered 20/11, 2017 at 6:19 Comment(0)
R
1

I have used the Open Clover Tool for the code coverage, I have also been searching this for a long time. Its pretty straightforward, in the Coverage Explorer tab, you can find three square buttons which says the code lines you wanted to display, click on hide the coverage square box and its gone. Last button in the image below: enter image description here

Regalado answered 26/9, 2018 at 17:17 Comment(0)
V
-1

Close the IDE and open it again. This works if you did not use any code coverage tools and have just clicked the basic "Coverage" icon in the IDE.

Vanzant answered 16/5, 2018 at 1:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.