Explain Codes LogoExplain Codes Logo

Clearing coverage highlighting in Eclipse

java
eclipse
ecobertura
coverage
Nikita BarsukovbyNikita Barsukov·Dec 28, 2024
TLDR

For swift Eclipse coverage highlights clearing:

  1. Go to Coverage View: Window > Show View > Other... > Java > Coverage.
  2. Right-click on the session under Coverage and hit Remove.
  3. If you're not seeing any highlight make sure the EclEmma plugin is up and running, it is the heart of coverage features.

Check Eclipse and EclEmma version compatibility. Some issues occur using Eclipse 4.2 due to compatibility issues.

Step-by-Step Instructions

Eclipse has a built-in progressive "Remove all Sessions" feature:

  1. Click on the "Remove All Coverage Sessions" button in the Coverage View toolbar.
    • /* If only removing bugs was this easy... */
  2. If the button is not visible, refreshingly update EclEmma to the latest version.
    • /* Keep up with the times, or the times leave you behind */
  3. You can get agile with keyboard shortcuts (Ctrl+W, Ctrl+Shift+F5).
  4. If you're rolling in the deep end with eCobertura, make minor edits and undo the changes to clear cache.

Troubleshooting Advice

In a universe where coverage sessions are stubborn and refuse to get removed, refer to these tips & tricks:

  1. If eCobertura gives you a hard time, try editing the code slightly (just add and remove a space).
    • /* Outsmart the smart. */
  2. If you’re working it old school with Eclipse 4.2 and eCobertura, it’s probably a good idea to upgrade or change lanes to a newer version.
    • /* Embrace the new, the old has stories to tell */
  3. If all else fails, EclEmma is always there for you.
  4. In Eclipse Juno, run configurations with exclusion filters like "*". It may resolve the issue.
    • /* Because, sometimes the easiest solution is the simplest one */

Tools and Alternatives

Coverage issues often lead us to crossroads. Here are some alternatives:

  1. Switch your weapon if current ones fail. Try alternatives.
    • /* Change is the only constant */
  2. A well-maintained version of eCobertura resides at GitHub: https://github.com/jmhofer/eCobertura/issues/8.
    • /* Community to the rescue! */
  3. Explore and tinker around with configuration settings or preferences. You might stumble upon a discovery.

Beyond the Basics

Here's a deep dive into Clearing Highlights in unconventional scenarios:

  • While Committing: Keep commits clean oasis in the desert of code.
  • During Code Reviews: To avoid the red bleed effect. Who needs Halloween all year round? Save it for October 31st!
  • Task switching: Clean slate, clean state.

When you need to clear coverage:

  • After running new tests for an accurate picture.
  • When the coverage is not synchronized with your actual code.
  • To keep the code looking neat and refrain from visual overload: Less is More.