0

I'm using Jacoco for creating a test coverage report and I also use the Parcelize Android extension plugin to create the methods needed for the Parcelables.

When I create the test reports the auto-generated functions are also appearing in the test coverages (e.g. createFromParcel(Parcel)) and of course they don't have any coverage.

How can I exclude those functions from my reports?

botflot
  • 275
  • 1
  • 4
  • 9

1 Answers1

1

I've looked how to do this for a while, and apparently Jacoco does ignore the auto-generated code as of version 0.8.2, but for this particular case, the CREATOR static field needed for the Parcelable interface to work is not ignored. So I had to test it. Though I couldn't easily find it accessible as a static field of my Parcelable class, so I had to get it using reflection:

val yourParcelableClassCreator = YourParcelableClass::class.java.getField("CREATOR").get(null) as Parcelable.Creator<YourParcelableClass>

After that, you can test its createFromParcel method normally and it will be reflected in your jacoco coverage.

César Muñoz
  • 535
  • 1
  • 6
  • 10