660

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?

tutejszy
  • 602
  • 7
  • 22
Charbel
  • 14,187
  • 12
  • 44
  • 66

10 Answers10

1128

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

enter image description here

Kai
  • 38,985
  • 14
  • 88
  • 103
  • 4
    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? – Umesh Rajbhandari Mar 15 '12 at 05:20
  • 4
    No that view comes from another plug-in. You should use the view "Coverage". – Kai Mar 15 '12 at 07:29
  • 4
    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. – James A Wilson Aug 07 '12 at 14:49
  • 1
    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? – Roger Sep 13 '12 at 14:41
  • See this for EclEmma plugin in eclipse http://www.eclemma.org/userdoc/coverageview.html – chinto Oct 05 '12 at 01:54
  • 1
    Helpful Note: the "Remove all Sessons" button is the black double X -- like the one you click to close all consoles – gMale Oct 25 '12 at 18:52
  • 8
    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. – Paul Drummond Dec 13 '12 at 15:51
  • 46
    The color of these two buttons is ridiculous. I was sure they were grayed out. – toniedzwiedz Jul 03 '13 at 09:29
  • 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. – Smart Coder Feb 06 '15 at 17:30
  • 1
    AFAICT, this completely deletes the information. You have to rerun the test to get it back. Is there a way to just hide it? – jordanpg Mar 02 '15 at 20:30
  • 2
    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. – Pieter12345 Jun 26 '18 at 20:59
  • 1
    I had to open the Coverage View from Window -> Show View -> Other -> search for Coverage, and then press the "Remove all Sessions"-button. – John Apr 09 '19 at 12:15
  • Thank you so much for this answer! This is super annoying when you first run across it. – atom88 Jun 24 '20 at 18:01
  • I actually mapped a key to it. There you need to know the full name indeed as Pieter12345 mentions: `Remove All Sessions`. – gkephorus Sep 13 '21 at 09:30
72

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.

Gábor Lipták
  • 9,646
  • 2
  • 59
  • 113
  • 1
    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 http://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. – Gábor Lipták Nov 19 '12 at 13:10
  • @Shervin Clover is really good, but of course you have to pay for it. For personal development, I think EclEmma is sufficient. – AHungerArtist Mar 09 '13 at 19:18
  • 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. – Vineet Bhatia Dec 05 '14 at 14:21
  • Modifying a Java file removes the coverage highlighting, but only for that file. Other relevant java files continue to show highlighting. – Don Smith Feb 17 '21 at 19:54
64

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

Divyanshu Jimmy
  • 2,542
  • 5
  • 32
  • 48
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.

Dan Hankins
  • 193
  • 1
  • 10
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

Sandeep Singh
  • 101
  • 1
  • 2
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.

Ryan2189
  • 81
  • 1
  • 1
7

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

asdf
  • 71
  • 1
  • 1
2

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.

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

Yash Bansal
  • 402
  • 5
  • 10
-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.

Satya
  • 576
  • 1
  • 6
  • 12