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

浪尽此生 提交于 2019-12-05 10:24:51
stevebot

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.

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

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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!