4

The only way I have found to not check code coverage on my JUnit tests is to right click on the package, choose Coverage as..., and then choose configuration. Then I can unclick my test package. I have tried every possible combination to exclude test under the general preferences/java/code coverage/exclude and not seen any changes. I always put my tests in a separate test source folder with the same package name as my src code.

Do I really have to configure every single project to ignore my JUnit tests? This seems redundant. Why would anyone want to check the coverage of their tests?

Godin
  • 9,801
  • 2
  • 39
  • 76
JesseBoyd
  • 1,022
  • 1
  • 13
  • 18
  • Possible duplicate http://stackoverflow.com/questions/12592881/ignore-code-coverage-for-unit-tests-in-eclemma and answer http://stackoverflow.com/a/12737106/227775 – dasrohith Aug 05 '16 at 12:36
  • I have read those questions, only the coverage config for every project works but as seen in some of those comments there is no permanent working solution that I can find that works and the question has not yet been solved. – JesseBoyd Aug 05 '16 at 17:52
  • It is eclemma's default setting to cover the src folders under the project. See http://www.eclemma.org/userdoc/preferences.html – dasrohith Aug 06 '16 at 02:56
  • @dasrohith - i set up my projects with a aPackage/src aPackage/test both of these folders are considered source folders. I don't think my tests would run if they were not classified as a source folder. – JesseBoyd Aug 08 '16 at 16:28
  • If your aim is just to get the coverage, you can use maven plugins like cobertura, they will show you the coverage report. If you want to get coverage inside eclipse(liek eclemma), I think sonar is a better option with code analysis and all. It is more configurable – dasrohith Aug 08 '16 at 17:46

2 Answers2

9

There is option Only path entries matching in Preferences -> Java -> Code Coverage that is described in documentation at http://www.eclemma.org/userdoc/preferences.html:

Comma separated list of strings that must match with the class path entry. A class path entry matches the filter, if it contains one of the given strings. (e.g. "src/main/java", Default: no filter)

Code Coverage Preferences

After setting it to src/main/java and running test that is located in src/test/java:

enter image description here

Godin
  • 9,801
  • 2
  • 39
  • 76
0

ECLEmma just excludes those files which are excluded , but it does not create creating coverage report and giving 0% coverage for that file , generating report

Finally ECL Emma not supporting this.

Nag-Raj
  • 169
  • 1
  • 4
  • 13