Releases: mannodermaus/android-junit5
Gradle Plugin 1.4.2.0
This release brings the compatibility to JUnit 5.4.2.
Instrumentation 1.0.0
The new instrumentation libraries are here! 🎉🎉🎉
dependencies {
androidTestImplementation "de.mannodermaus.junit5:android-test-core:1.0.0"
androidTestRuntimeOnly "de.mannodermaus.junit5:android-test-runner:1.0.0"
}
(More info regarding the setup can be found in the README, and shortly on the Wiki. Also, please allow some time for the new artifacts to become available on JCenter - their submission is currently pending.)
Getting to know the new libraries
The integration of JUnit 5 into Android instrumentation tests has never been easier. We introduce a new core library, and a revamped runner to execute the new tests on supported devices!
-
The best news upfront: The high
minSdkVersion
requirement has been removed. Of course, JUnit 5 tests will still only run on devices with supported software (i.e. Android 8.0/API 26 or higher). However, you won't need to create custom flavors to host your tests any longer. If you execute a test suite containing JUnit 5 tests on an older device, the test runner will simply ignore the new tests. -
@ActivityTest
is deprecated. With Google's push towards a unified testing API, the new JUnit 5 core library for Android tests has also migrated to the newActivityScenario
API. There is an extension which you can drop into your classes, granting access to an underlying scenario, very much like theActivityScenarioRule
would do. -
The "old" instrumentation library is now deprecated. Please use
android-test-core
from now on!
Gradle Plugin 1.4.1.0
This release brings the compatibility up to JUnit 5.4.1.
Gradle Plugin: 1.3.2.0
This release brings compatibility with Gradle 5, as well as a few QOL improvements.
Added
Changed
- Updated JUnit 5 dependencies to 5.3.2 (#132)
- Converted all helper classes for unit tests to Kotlin & inverted the dependency between Kotlin and Groovy. Now, the only Groovy thing left in that particular module are some unit tests (#136)
- Moved to a type-safe way to declare libraries & versions in Kotlin DSL, instead of relying on the
extra
API in Gradle (#137)
Fixed
Removed
- The plugin no longer tries to configure modules that use the
com.android.test
plugin. These modules only use instrumentation tests, and do not expose any unit test tasks. If you want JUnit 5 in these modules, use the instrumentation test libraries instead (#134)
Gradle Plugin: 1.3.1.1
This release improves the usability of the plugin for users of the Kotlin DSL for Gradle.
Added
Although not directly related to the artifact itself, the Wiki has received some love for usage with the Kotlin DSL. There are now "Getting Started" guides for both Groovy and Kotlin users.
Changed
DSL methods have been unified, so that instead of exposing two variants for Kotlin and Groovy, a single signature using Gradle's Action<T>
is exposed to consumers.
If you were using Kotlin DSL with this plugin before, this can potentially be a breaking change. Because of the improved SAM interface integrations for both languages, usage of android-junit5 is now a lot cleaner in Kotlin.
1.3.1.0:
android.testOptions {
junitPlatform {
filters("debug", config = {
// Configure the filter
})
}
}
1.3.1.1:
android.testOptions {
junitPlatform {
filters("debug") {
// Configure the filter
}
}
}
Gradle Plugin: 1.3.1.0
Updates the transitive dependency on JUnit Platform to 1.3.1
, Jupiter to 5.3.1
and Vintage to 5.3.1
.
Added
- #115 Support for
com.android.dynamic-feature
plugin (thanks to @CedrickFlocon)
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
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
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
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 intoandroid.TestOptions.junitPlatform
! - Removed: The
junitPlatform.jacoco
container had been renamed tojacocoOptions
; with this release, the old container is now gone.
Gradle Plugin: 1.0.30
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"
// ...
}
}
}