android-analyzer icon indicating copy to clipboard operation
android-analyzer copied to clipboard

Espresso Test Coverage Support

Open joshafeinberg opened this issue 6 years ago • 3 comments

Can we get a flag that allows us to include espresso test coverage in our test coverage report?

joshafeinberg avatar Dec 12 '19 21:12 joshafeinberg

At the moment that's not possible. I'll investigate if that is feasible, and perhaps add it into 2.0.0 release, along with other larger features.

AndroideRob-zz avatar Dec 18 '19 11:12 AndroideRob-zz

It should be possible when not using the test orchestrator's clear package data flag.

cs showing the boolean you care about: https://cs.android.com/android/platform/superproject/+/master:tools/base/build-system/gradle-core/src/main/groovy/com/android/build/gradle/internal/model/BuildTypeImpl.java?q=testCoverageEnabled

so its on the BuildType so that makes me think at least this is an option:

android {
  buildTypes {
    debug {
      testCoverageEnabled = true
    }
  }
}

since android has no jvm agents it tracks coverage via compile time bytecode instrumentation. brace yourself for longer build times when that is turned on.

it might be useful to see if it can be set via flavor rather than just type and have a dedicated flavor for instrumentation runs and/or add a project property lookup to decide if it should be true or false.

bug about test orchestrator clear data issue: https://issuetracker.google.com/issues/123987001

trevjonez avatar Dec 18 '19 16:12 trevjonez

Great, thank you for the insight.

I am planning to separate test and analysis tasks (currently analysis task will always run tests first).

This would allow adding instrumentation test coverage flag along with unit test coverage flag.

I'm creating a list of features for the 2.0.0 release, and this will be one of them.

AndroideRob-zz avatar Dec 20 '19 11:12 AndroideRob-zz