683

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?

10 Answers 10

1154

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

enter image description here

15
  • 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? Commented Mar 15, 2012 at 5:20
  • 4
    No that view comes from another plug-in. You should use the view "Coverage".
    – Kai
    Commented Mar 15, 2012 at 7: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. Commented Aug 7, 2012 at 14:49
  • 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. Commented Dec 13, 2012 at 15:51
  • 49
    The color of these two buttons is ridiculous. I was sure they were grayed out. Commented Jul 3, 2013 at 9:29
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.

4
  • 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 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. Commented Nov 19, 2012 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. Commented Mar 9, 2013 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. Commented Dec 5, 2014 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
    Commented Feb 17, 2021 at 19:54
69

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

1
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.

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

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.

2
  • 4
    Seems a bit crude. Isn't there any other way? Commented Nov 19, 2012 at 12:56
  • 3
    Restarting is not feasible.. if you are doing lot of testing with code coverage.
    – mtk
    Commented Sep 30, 2013 at 15:02
7

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

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.

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

-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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.