Skip to content

Gradle Plugin: 1.0.22

Compare
Choose a tag to compare
@mannodermaus mannodermaus released this 03 Dec 23:14
· 464 commits to main since this release
6f1db59

The next version of our Gradle Plugin brings quite a few deprecations alongside brand-new functionality & fixes! Please read the Migration section carefully to upgrade properly.

New Features

Support for Instrumentation Tests

For the first time, you can run instrumented tests (i.e. on-device tests, driven by frameworks like Espresso) with the JUnit Platform! The plugin can configure your project in a way that enhances the default Test Instrumentation Runner with JUnit 5-based functionality. For the curious, we're currently subject to the same limitations that the JUnit Platform Runner has, so only a subset of JUnit 5 features will work in instrumented tests at this time. It's enough to get started with most things you would need, though, so try it out for yourself!

Instrumented Test Support is disabled by default, since its minSdkVersion requirement is pretty steep, and the feature itself is still incubating. First, you need to enable it explicitly, then include the junit5.instrumentationTests() library into your dependencies block:

android {
  testOptions {
    junitPlatform {
      instrumentationTests.enabled true
    }
  }
}

dependencies {
  androidTestImplementation junit5.instrumentationTests()
}

A User Guide for writing instrumentation tests is coming, so please stay tuned for that.

Fixes

The following issues have been addressed in this version:

  • #34 Unable to find method during gradle sync
  • #36 Running tests on multiple flavors
  • #37 Move junitPlatform configuration into android namespace enhancement
  • #38 Delete duplicated Jacoco config, obey the default

Migration

Move the config closure

The junitPlatform closure added by the plugin has been moved from being a top-level extension, to a new location inside android.testOptions. This resonates with the canon of the Android Gradle Plugin's testing-related options.

Before

junitPlatform {
  jupiterVersion "..."
  details "..."
  // more here...
}

After

android {
  testOptions {
    junitPlatform {
      jupiterVersion "..."
      details "..."
      // more here...
    }
  }
}

Update your dependencies

The JUnit 5 dependency handlers have been refactored yet again. With the addition of support for instrumentation tests, the current set of names didn't feel accurate enough anymore.

Before

testImplementation junit5()
testImplementation junit5Params()
testCompileOnly junit5EmbeddedRuntime()

After

testImplementation junit5.unitTests()
testImplementation junit5.parameterized()
testCompileOnly junit5.unitTestsRuntime()

Review your Jacoco integration

The Jacoco extension has been polished and extended to resemble its respective's plugin a little more.

Before

junitPlatform {
  jacoco {
    xmlReport true
    htmlReport true
    csvReport true
}

After

android {
  testOptions {
    junitPlatform {
      jacoco {
        xml {
          enabled true
          destination project.file()
        }
        html {
          enabled true
          destination project.file()
        }
        csv {
          enabled true
          destination project.file()
        }
      }
    }
  }
}