0

Maybe it is a naive question, but I am running the source code of a java application on eclipse and I need to extract one specific functionality from all the application. Is there any way to highlight or identify the chunk of codes which were not ran after an execution?. I am using Eclipse 2018-09.

Thank you so much.

  • I am not sure what are you asking for. Anyway, you can put `System.out.println` statement with some random text in your block to make sure whether it is executed or not. – Tanzeel Sep 18 '19 at 04:14
  • 1
    Run the program with code coverage option? See [Eclemma](http://www.eclemma.org/) – Ashvin Sharma Sep 18 '19 at 04:27
  • But note: "unrun" code depends on how exactly your "drive" your application when measuring coverage. – GhostCat Sep 18 '19 at 05:06

2 Answers2

0

One way to identify which code were executed is to write a test case and run java code coverage maven plugin or run sonar for the test case, if you are using maven project. jacoco-maven-plugin is the plugin name. You can check more details in https://medium.com/capital-one-tech/improve-java-code-with-unit-tests-and-jacoco-b342643736ed.

Sujay Mohan
  • 933
  • 7
  • 14
0

You can install SonarLint plugin

How to install SonarLint to eclipse , Follow the steps here

  1. Click on Help
  2. Eclipse Market Place
  3. Search , SonarLint plugin
  4. SonarLint plugin can be found in Eclipse MarketPlace by searching
  5. Restart eclipse
  6. you will see under line error that chunk of codes which were not used to anything
Dulaj Kulathunga
  • 1,248
  • 2
  • 9
  • 19