5

I am using EclEmma (inside of Eclipse) to scan my JUnit code coverage. This works correctly - however, I do not want EclEmma to scan my src/view folder since it contains Swing code that I consider not worthy of testing.

Is there any way to ignore this folder when EclEmma runs so that it: a) runs faster, and b) does not skew the coverage percentage?

EDIT:

My project's structure is:

src/view
src/model
src/controller

I have tried these (possibly others) with the Path Entries section in the Preferences page:

"src/view"
"src/view/*"
"view"
"view/*"
src/view

These are using the Excludes section in the Preferences page:

*
*View*
*View*.class
src/view/*View*
src/view/*View*.class

They all leave me with the same result of it analysing my entire src folder.

sdasdadas
  • 23,917
  • 20
  • 63
  • 148

3 Answers3

6

[Edit] The maintainers says you cannot, except one the source directory level: https://github.com/jacoco/eclemma/issues/70

I thought eclemma wasn't excluding files: it is. Just not as I thought.

When you go into excludes in preferences and specify your.classes.here.*, for example, that means those classes won't count towards your getting all your code covered, not that those classes won't be included in what needs to be covered by tests.

Try it and see. Try to exclude a class you know have coverage in it. Once you put that to the excludes preference, on a new coverage run they'll still be there in the coverage window, but they'll come up as 0% and will all be in red.

Rather useless if you ask me. I'm still searching for an adequate solution to exclude classes by name from the classes that need to be covered by tests.

mmm111mmm
  • 3,607
  • 4
  • 27
  • 44
5

You can specify an exclude field:

Excludes: A list of class names that should be excluded from execution analysis. The list entries are separated by a colon (:) and may use wildcard characters (* and ?). (Default: empty)

However, it might be easier to use their options for classpath matching:

Only path entries matching: 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)

See eclemma - how to ignore source about how to ignore src folders.

Also please note their caution,

Warning: If your settings do not match any of the class path entries in your project(s), every new launch in coverage mode will have an empty analysis scope.

Community
  • 1
  • 1
stevebot
  • 23,275
  • 29
  • 119
  • 181
  • 1
    Thanks, that looks like what I want. Unfortunately, when I used the pattern com.test.project.view.* in the Excludes, it doesn't seem to excluse anything. EDIT: Whoops, I didn't notice it said class names... – sdasdadas Jan 21 '13 at 23:02
  • I believe this is the correct answer but I don't believe it actually works in EclEmma. I'm accepting but if anyone should read this please know that I cannot figure out how to include OR excluse classes or paths. – sdasdadas Jan 21 '13 at 23:12
  • @sdasdadas Sorry to hear that, could you post what you have tried? If there are any typos it won't work at all. – stevebot Jan 21 '13 at 23:21
  • I've tried a few things in both categories. Mostly just permutations: *View*, *View*.class, src/view/*, src/view, src/view/, "src/view", -"src/view", and basically all of the different combinations of those features. I've tried excluding everything which doesn't seem to work either... – sdasdadas Jan 21 '13 at 23:23
  • Just in response to your last edit, every thing I've tried has not left the scope blank - it just leaves every class in so it's including everything. – sdasdadas Jan 21 '13 at 23:24
  • @sdasdadas Ok, would you be willing to update your question to include your project's structure and also some examples that do not work? – stevebot Jan 21 '13 at 23:25
  • Sure, give me a few minutes. – sdasdadas Jan 21 '13 at 23:29
  • This: **/*domain*.* excludes anything with 'domain' in the path. Unfortunately it continues to add the total lines to the metrics so it does not do what it should do. I am not sure what this would be worth! – markthegrea Apr 19 '16 at 18:07
1

I have given up on EclEmma because I can't get it to do the things I want it to do, so I use a different method - I'll document it here in case it helps anyone else.

  1. To exclude classes from test, I name all my test classes as *Case.java and then include or exclude them via SuiteClasses. You can read more about that at https://github.com/junit-team/junit4/wiki/Aggregating-tests-in-suites
  2. To measure coverage, I use Maven and Cobertura. This will test just the files specified in my test suites and produce coverage reports accordingly.
Stoat
  • 117
  • 9