3

We use cobertura to measure code coverage in unit testing and integrated/system testing.

Some classes are more note suitable for getting a coverage in plain unit test. (Some require database, GUI testing etc). While mock objects, stubs, gui-unit-testing framework will help here, we are considering a way to mark some classes not to be included in instrumentation.

Cobertura provides a pattern based processing to include/exclude classes. Is there a way to annotate class and skip from instrumenting?

Without above, I will have to write a custom annotation processor to get list of classes, and then user the result to skip from instrumenting phase.

Jayan
  • 18,003
  • 15
  • 89
  • 143
  • 1
    See also [this question](http://stackoverflow.com/questions/951569/exclude-code-from-code-coverage-with-cobertura). The comments to the selected answer suggest that such an annotation processor does not exist (and that the community might be interested in your processor...) – avandeursen Jul 18 '11 at 07:57

1 Answers1

1

if you are using Ant to run cobertura this uses fileset so you could use the excludesFile parameter to specify a file containing a list of files to ignore.

This list of files could be produced by a custom annotation parser or you could stick a unique comment in the files and search for that maybe something like

for file in `find ./ -name '*.java'`; do if grep --silent "some unique tag" $file ;then echo $file > excludeFile.lst; fi ; done
default_avatar
  • 306
  • 3
  • 14