Testing Singh
Testing Singh

Reputation: 1353

Jenkins JaCoCo Coverage with multiple classes with "$"

Using JaCoCo Emma Jenkins Plugin for a long time and successfully getting code coverage metrics but have some repetition of classes with "$" sign. Which brings down line coverage metrics. E.g. ClassName.class but have multiple classes with:

  1. ClassName$1
  2. ClassName$2
  3. ClassName$3
  4. ClassName$4 and so on

I can just ignore them it brings up the metrics but wondrering why it shows up and it that ok to ignore them?

enter image description here

Upvotes: 2

Views: 879

Answers (1)

lax1089
lax1089

Reputation: 3473

As stated in comment, these are anonymous inner classes and should be treated as if they were different classes for the purposes of code coverage. Therefore, if your tests are not hitting some/most of the code in these inner classes, your code coverage will be (and should be) lower.

You can exclude them if you want (by adding **/*$* to Exclusions section of JaCoCo plugin config), but I HIGHLY advise you not to do that.

The right way to fix your problem is to create test cases which hit the missed code in these inner classes.

Upvotes: 1

Related Questions