Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I ignore scanning certain classes using EclEmma and Eclipse?

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.

like image 967
sdasdadas Avatar asked Jan 21 '13 22:01

sdasdadas


People also ask

How can you appropriately exclude a class from code coverage analysis in eclipse?

The easiest way to exclude code from code coverage analysis is to use the ExcludeFromCodeCoverage attribute. This attribute tells tooling that a class or some of its members are not planned to be covered with the tests.

How do you exclude a class from code coverage?

The easiest way to exclude code from code coverage analysis is to use ExcludeFromCodeCoverage attribute. This attribute tells tooling that class or some of its members are not planned to be covered with tests. EditFormModel class shown above can be left out from code coverage by simply adding the attribute.


1 Answers

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

like image 147
mmm111mmm Avatar answered Oct 13 '22 22:10

mmm111mmm