Skip to content

Releases: mannodermaus/android-junit5

Gradle Plugin: 1.3.1.0

28 Oct 19:10
Compare
Choose a tag to compare

Updates the transitive dependency on JUnit Platform to 1.3.1, Jupiter to 5.3.1 and Vintage to 5.3.1.

Added

Fixed

  • #110 DSL issue in projects with multi-dimensional product flavors
  • Support for Android Gradle Plugin 3.3.0-alpha13 and above

Gradle Plugin: 1.2.0.0

11 Oct 10:01
0363d60
Compare
Choose a tag to compare

This is the go-to release for all applications running with the Android Gradle Plugin 3.2.0 and newer, and probably the biggest change since the original release of JUnit 5.0. We move to native Gradle support for JUnit 5 and remove quite a few APIs from the previous version, which also doesn't support the latest Gradle versions anymore.

To see details about the new configuration DSL, check out the Wiki. Furthermore, if you want to upgrade from 1.0.32, check out the Wiki!

Gradle Plugin: 1.0.32

03 May 04:59
Compare
Choose a tag to compare

This release enhances compatibility with Android Gradle Plugin 3.2.0 alpha versions (verified until alpha13), as well as some fixes related to JaCoCo, and new DSL to mirror behavior found in the default test options. It also updates the android-instrumentation-test library dependency to 0.2.2. If you explicitly depend on an earlier version in your build.gradle, please update.

Architecture Changes

  • The plugin doesn't depend on the (now deprecated) junit-platform-gradle-plugin anymore. As a result, the majority of code is now fully converted to Kotlin, including the exposed DSLs and extension functions. This will hopefully facilitate the integration with Gradle projects utilizing kotlin-dsl as well.

Behavior Changes

  • Fix: If a project integrates with Kotlin, but the Kotlin plugin is applied after android-junit5, a warning is generated during configuration time. There is a fallback for attaching the Kotlin source directories manually, however, so the JUnit Platform can detect Kotlin files even in this state.
  • Fix: The JaCoCo integration now configures the source directories correctly, which allows Code Preview to display coverage across files from the reports.

API Changes

  • New: junitPlatform.unitTests.returnDefaultValues defines the behavior of calling unmocked methods on Android SDK types in unit tests. Equivalent to the well-known property of the same name in the default Android test options.
  • New: junitPlatform.unitTests.includeAndroidResources defines if Android resources, assets and manifests should be accessible in unit tests. Equivalent to the well-known property of the same name in the default Android test options.

Gradle Plugin: 1.0.31

03 Mar 16:01
Compare
Choose a tag to compare

This release enhances the compatibility for instrumentation tests with JUnit 5, improves internally by raising the minimum required Gradle version, and removes some deprecated APIs. It also updates the android-instrumentation-test library dependency to 0.2.1. If you explicitly depend on an earlier version in your build.gradle, please update.

Instrumentation Tests

Instrumentation Test Support is now transparently enabled by default, however you won't notice the impact of its minSdkVersion 26 requirement if you don't want to. At most, you will see an innocuous statement in your Logcat, but that's it:

E/TestLoader: Could not find class: de.mannodermaus.junit5.AndroidJUnit5

This refers to JUnit 5 detection being silently turned off if it doesn't detect the required runtime dependencies, which you provide through the junit5.instrumentationTests() dependency handler. If you do provide JUnit 5 tests though, they will be picked up by the Android Test Runner, and included in the resulting reports.

Creating a product flavor for experiments with JUnit 5 instrumentation tests is a great way of getting to know the new APIs in a safe way. Consult the sample application's build.gradle for how this can be done.

Minimum Gradle Version

Previously, the android-junit5 plugin mirrored its big brother's minimum Gradle requirement, which was 2.5+. With this release, this requirement was upgraded to 4.3+. This helps with internal house-keeping, as well as migration to new APIs exposed by Gradle.

With first-party support for JUnit 5 in recent versions of Gradle, expect this minimum requirement to go up even further in the future. Consult the README for a new section on minimum required Gradle versions.

API Changes

  • New: junitPlatform.unitTests.all can be used to configure JUnit test tasks (JVM arguments, environment variables, system properties)
  • New: junitPlatform.jacocoOptions.taskGenerationEnabled can be used to turn off automatic generation of Jacoco companion tasks if the plugin is applied alongside android-junit5
  • New: junitPlatform.jacocoOptions.onlyGenerateTasksForVariants can be used to specify Build Variants that should be provided with Jacoco companion tasks; all other variants won't get one. By default, this is an empty list, which will cause all variants to factor into task generation
  • Removed: The top-level junitPlatform closure is now gone. Move your configuration into android.TestOptions.junitPlatform!
  • Removed: The junitPlatform.jacoco container had been renamed to jacocoOptions; with this release, the old container is now gone.

Gradle Plugin: 1.0.30

22 Jan 13:58
d2024eb
Compare
Choose a tag to compare

This release brings compatibility with JUnit 5.0.3.

Migration

The jacoco DSL container was renamed to jacocoOptions, to avoid a false-positive deprecation notice in the IDE related to the original Jacoco integration of the Android Gradle Plugin. Ironically enough, the jacoco container is actually deprecated now!

To migrate, simply replace with jacocoOptions:

android.testOptions {
  junitPlatform {
    jacoco {
      excludedClasses += "Unrelated.class"
      // ...
    }
  }
}

->

android.testOptions {
  junitPlatform {
    jacocoOptions {
      excludedClasses += "Unrelated.class"
      // ...
    }
  }
}

Gradle Plugin: 1.0.22

03 Dec 23:14
6f1db59
Compare
Choose a tag to compare

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()
        }
      }
    }
  }
}

Instrumentation Test Library: 0.1.1

03 Dec 22:56
6f1db59
Compare
Choose a tag to compare

Please welcome the first "real" library release of the Instrumentation Test companion library for JUnit 5! I'm pretty stoked that we finally have an intermediate solution to driving instrumentation tests on Android with the JUnit Platform.

While the User Guide is still in development, here's a small gist of how to use it with the latest Gradle plugin (1.0.22):

  1. Update your minSdkVersion to 26 or higher
  2. Enable JUnit 5 instrumented tests in the plugin:
    android.testOptions {
      junitPlatform {
        instrumentationTests.enabled true
      }
    }
  3. Add the dependency on the companion library:
    dependencies {
      androidTestImplementation junit5.instrumentationTests()
    }
  4. Create a test class, extend it with @ActivityTest and add a parameter of type Tested to your test methods (optional):
    @ActivityTest(MyActivity::class)
    class InstrumentationTests {
      @Test
      fun someTest(tested: Tested<MyActivity>) {
        // Do your assertions (e.g. Espresso, ...)
      }
    }

1.0.20

20 Nov 12:48
Compare
Choose a tag to compare

This release brings compatibility with JUnit 5.0.2.

This version replaces the Copy task for Kotlin-based unit tests, which was prevalent in the previous versions of the plugin. Since the IDE integration seems to have improved greatly and Kotlin tests are properly detected from within Android Studio, the requirement to copy over the classes has been lifted. Now, the plugin is configuring JUnit 5 directly to allow these tests to run from the command line via Gradle, as well.

In other news, the plugin is now almost entirely written in Kotlin. The test scope remains in Groovy because of the frameworks in place, but moving to Kotlin for the main portion of the plugin feels great as an outlook forward!

1.0.12

02 Nov 14:35
Compare
Choose a tag to compare

This is a bug fix update for the integration with JUnit 5.0.1.

Fixed

  • #25 Product Flavor tasks don't find their (Kotlin) tests properly

1.0.10

10 Oct 04:30
Compare
Choose a tag to compare

This release brings compatibility with JUnit 5.0.1.

I'm unapologetically copying the Kotlin versioning scheme for this plugin from now on. A four-component semantic version raises a few issues with the existing build tools & IDEs (e.g. when detecting "more recent" versions against SNAPSHOTs), so I'm moving to a three-component version mirroring the JUnit Platform version, and the additional final digit denoting patches inside the plugin itself, unrelated to JUnit advancements.

New

  • JaCoCo is now automatically hooked into the JUnit 5 task creation process. The plugin will detect if you also apply the jacoco plugin to your project, and configure additional Report tasks accordingly.
  • junit5EmbeddedRuntime(): A new dependency handler to deal with the Android Studio workaround related to outdated APIs - replace the old explicit artifact (android-junit5-embedded-runtime) with this and you're good to go.