Skip to content

Commit 9db3b52

Browse files
committed
Happy New Year! Update readme & prepare next version
1 parent 1f67f0f commit 9db3b52

4 files changed

Lines changed: 70 additions & 40 deletions

File tree

README.md

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414
[![CircleCI](https://circleci.com/gh/mannodermaus/android-junit-framework/tree/main.svg?style=svg)][circleci]
1515

16-
A Gradle plugin that allows for the execution of [JUnit Framework][junit-framework-github] tests in Android environments using **Android Gradle Plugin 8.2 or later.**
16+
A Gradle plugin that allows for the execution of [JUnit][junit-github] 5+ tests in Android environments using **Android Gradle Plugin 8.2 or later.**
1717

1818
## How?
1919

2020
This plugin configures the unit test tasks for each build variant of a project to run on the JUnit Platform.
2121
Furthermore, it provides additional configuration options for these tests [through a DSL][wiki-dsl]
22-
and facilitates the usage of JUnit Framework for instrumentation tests.
22+
and facilitates the usage JUnit for instrumentation tests.
2323

24-
Instructions on how to write tests with the JUnit Framework can be found [in their User Guide][junit-framework-guide].
24+
Instructions on how to write tests with modern JUnit can be found [in their User Guide][junit-guide].
2525
To get a first look at its features, a small showcase project can be found [here][sampletests].
2626

2727
## Setup
@@ -32,17 +32,17 @@ Snapshots of the development version are available through [Sonatype's `snapshot
3232
```kotlin
3333
plugins {
3434
// 1. Apply the plugin
35-
id("de.mannodermaus.android-junit5") version "1.14.0.0"
35+
id("de.mannodermaus.android-junit") version "2.0.0"
3636
}
3737

3838
dependencies {
39-
// 2. Add JUnit Framework BOM and the required dependencies
39+
// 2. Add JUnit BOM and the required dependencies
4040
testImplementation(platform("org.junit:junit-bom:5.14.1"))
4141
testImplementation("org.junit.jupiter:junit-jupiter-api")
4242
testImplementation("org.junit.jupiter:junit-jupiter-params")
4343
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
4444

45-
// 3. Add JUnit Vintage if you also have JUnit 4 tests (e.g. Robolectric)
45+
// 3. Add JUnit Vintage if you also have JUnit 4 tests (e.g. for Robolectric)
4646
testImplementation("junit:junit:4.13.2")
4747
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
4848
}
@@ -59,11 +59,11 @@ The latest version of this plugin requires at least:
5959
## Instrumentation Test Support
6060

6161
You can also write instrumentation tests with new JUnit APIs and execute them on emulators and physical devices.
62-
Depending on the Java requirements of the JUnit Framework version, these instrumentation tests will only run on devices
63-
that meet these requirements, however. These tests are ignored and their execution will be skipped on older devices.
62+
Depending on the Java requirements of the JUnit version, these instrumentation tests will only run on devices
63+
that meet these requirements, however. On older devices, an exception will be raised at runtime.
6464

65-
- JUnit 5 requires Java 8 and is only supported by devices running Android 8.0 (API 26) or newer
66-
- **(Coming soon)** JUnit 6 requires Java 17 and is only supported by devices running Android 15 (API 35) or newer
65+
- JUnit 5 requires Java 8; devices require at least Android 8.0 (API 26)
66+
- JUnit 6 requires Java 17; devices require at least Android 15 (API 35)
6767

6868
Before you can write instrumentation tests with JUnit Jupiter,
6969
make sure that your module is using the `androidx.test.runner.AndroidJUnitRunner`
@@ -78,9 +78,21 @@ dependencies {
7878
}
7979
```
8080

81-
By enabling JUnit Framework for instrumentation tests, you will gain access to `ActivityScenarioExtension` among other things,
81+
By enabling JUnit for instrumentation tests, you will gain access to `ActivityScenarioExtension` among other things,
8282
which helps with the orchestration of `Activity` classes. Check [the wiki][wiki-home] for more info.
8383

84+
### Ignoring older devices
85+
86+
Historically, tests were ignored if the Android device running them did not meet the requirements of JUnit.
87+
This was changed in the 2.0.0 of the plugin & library, but if you want to restore the previous behavior,
88+
you can do so via the `junitPlatform` DSL.
89+
90+
```kotlin
91+
junitPlatform {
92+
instrumentationTests.behaviorForUnsupportedDevices = UnsupportedDeviceBehavior.Skip
93+
}
94+
```
95+
8496
### Extensions
8597

8698
An optional artifact with `extensions` is available for specific use cases. It contains the following APIs:
@@ -91,13 +103,13 @@ Can you think of more? Let's discuss in the issues section!
91103

92104
```kotlin
93105
junitPlatform {
94-
instrumentationTests.includeExtensions.set(true)
106+
instrumentationTests.includeExtensions = true
95107
}
96108
```
97109

98110
### Jetpack Compose
99111

100-
To test `@Composable` functions on devices compatible with the JUnit Framework,
112+
To test `@Composable` functions on devices compatible with modern JUnit,
101113
enable support for instrumentation tests as described above. Then add the Compose test dependency
102114
to your `androidTestImplementation` configuration and the plugin will autoconfigure JUnit 5 Compose support for you.
103115

@@ -122,7 +134,7 @@ when it sets up the artifacts automatically. However, it is possible to choose a
122134

123135
```kotlin
124136
junitPlatform {
125-
instrumentationTests.version.set("1.9.0")
137+
instrumentationTests.version = "2.0.0"
126138
}
127139
```
128140

@@ -137,7 +149,7 @@ The following list is an aggregation of pending feature requests:
137149

138150
## Support for @Rules
139151

140-
Since the JUnit Framework has replaced the `@Rule` mechanism with the concept of an `Extension`,
152+
Since JUnit has replaced the `@Rule` mechanism with the concept of an `Extension` in version 5,
141153
the following artifacts help bridge the gap until Android officially transitions, if ever.
142154

143155
### InstantExecutorExtension
@@ -169,7 +181,7 @@ so please consider upgrading to at least AGP 8.2 before filing an issue with the
169181

170182
|Your AGP Version|Suggested Plugin Version|
171183
|---|---|
172-
|`>= 8.2.0`|`1.14.0.0`|
184+
|`>= 8.2.0`|`2.0.0`|
173185
|`8.0.0` - `8.1.4`|`1.12.2.0`|
174186
|`7.0.0` - `7.4.2`|`1.10.0.0`|
175187
|`4.0.0` - `4.2.2`|`1.8.2.1`|
@@ -179,7 +191,7 @@ so please consider upgrading to at least AGP 8.2 before filing an issue with the
179191
## License
180192

181193
```
182-
Copyright 2017-2025 Marcel Schnelle
194+
Copyright 2017-2026 Marcel Schnelle
183195
184196
Licensed under the Apache License, Version 2.0 (the "License");
185197
you may not use this file except in compliance with the License.
@@ -196,8 +208,8 @@ limitations under the License.
196208

197209
See also the [full License text](LICENSE).
198210

199-
[junit-framework-github]: https://github.com/junit-team/junit-framework
200-
[junit-framework-guide]: https://docs.junit.org
211+
[junit-github]: https://github.com/junit-team/junit-framework
212+
[junit-guide]: https://docs.junit.org
201213
[circleci]: https://circleci.com/gh/mannodermaus/android-junit-framework
202214
[sonatyperepo]: https://central.sonatype.com/repository/maven-snapshots
203215
[sampletests]: instrumentation/sample

README.md.template

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
[![CircleCI](https://circleci.com/gh/mannodermaus/android-junit-framework/tree/main.svg?style=svg)][circleci]
1010

11-
A Gradle plugin that allows for the execution of [JUnit Framework][junit-framework-github] tests in Android environments using **Android Gradle Plugin ${constants.minimumRequiredAgpVersion} or later.**
11+
A Gradle plugin that allows for the execution of [JUnit][junit-github] 5+ tests in Android environments using **Android Gradle Plugin ${constants.minimumRequiredAgpVersion} or later.**
1212

1313
## How?
1414

1515
This plugin configures the unit test tasks for each build variant of a project to run on the JUnit Platform.
1616
Furthermore, it provides additional configuration options for these tests [through a DSL][wiki-dsl]
17-
and facilitates the usage of JUnit Framework for instrumentation tests.
17+
and facilitates the usage JUnit for instrumentation tests.
1818

19-
Instructions on how to write tests with the JUnit Framework can be found [in their User Guide][junit-framework-guide].
19+
Instructions on how to write tests with modern JUnit can be found [in their User Guide][junit-guide].
2020
To get a first look at its features, a small showcase project can be found [here][sampletests].
2121

2222
## Setup
@@ -27,17 +27,17 @@ Snapshots of the development version are available through [Sonatype's `snapshot
2727
```kotlin
2828
plugins {
2929
// 1. Apply the plugin
30-
id("de.mannodermaus.android-junit5") version "${pluginVersion}"
30+
id("de.mannodermaus.android-junit") version "${pluginVersion}"
3131
}
3232

3333
dependencies {
34-
// 2. Add JUnit Framework BOM and the required dependencies
34+
// 2. Add JUnit BOM and the required dependencies
3535
testImplementation(platform("${libs.junit.framework.bom5}"))
3636
testImplementation("${libs.junit.jupiter.api}")
3737
testImplementation("${libs.junit.jupiter.params}")
3838
testRuntimeOnly("${libs.junit.jupiter.engine}")
3939

40-
// 3. Add JUnit Vintage if you also have JUnit 4 tests (e.g. Robolectric)
40+
// 3. Add JUnit Vintage if you also have JUnit 4 tests (e.g. for Robolectric)
4141
testImplementation("${libs.junit.vintage.api}")
4242
testRuntimeOnly("${libs.junit.vintage.engine}")
4343
}
@@ -54,11 +54,11 @@ The latest version of this plugin requires at least:
5454
## Instrumentation Test Support
5555

5656
You can also write instrumentation tests with new JUnit APIs and execute them on emulators and physical devices.
57-
Depending on the Java requirements of the JUnit Framework version, these instrumentation tests will only run on devices
58-
that meet these requirements, however. These tests are ignored and their execution will be skipped on older devices.
57+
Depending on the Java requirements of the JUnit version, these instrumentation tests will only run on devices
58+
that meet these requirements, however. On older devices, an exception will be raised at runtime.
5959

60-
- JUnit 5 requires Java 8 and is only supported by devices running Android 8.0 (API 26) or newer
61-
- **(Coming soon)** JUnit 6 requires Java 17 and is only supported by devices running Android 15 (API 35) or newer
60+
- JUnit 5 requires Java 8; devices require at least Android 8.0 (API 26)
61+
- JUnit 6 requires Java 17; devices require at least Android 15 (API 35)
6262

6363
Before you can write instrumentation tests with JUnit Jupiter,
6464
make sure that your module is using the `androidx.test.runner.AndroidJUnitRunner`
@@ -73,9 +73,21 @@ dependencies {
7373
}
7474
```
7575

76-
By enabling JUnit Framework for instrumentation tests, you will gain access to `ActivityScenarioExtension` among other things,
76+
By enabling JUnit for instrumentation tests, you will gain access to `ActivityScenarioExtension` among other things,
7777
which helps with the orchestration of `Activity` classes. Check [the wiki][wiki-home] for more info.
7878

79+
### Ignoring older devices
80+
81+
Historically, tests were ignored if the Android device running them did not meet the requirements of JUnit.
82+
This was changed in the 2.0.0 of the plugin & library, but if you want to restore the previous behavior,
83+
you can do so via the `junitPlatform` DSL.
84+
85+
```kotlin
86+
junitPlatform {
87+
instrumentationTests.behaviorForUnsupportedDevices = UnsupportedDeviceBehavior.Skip
88+
}
89+
```
90+
7991
### Extensions
8092

8193
An optional artifact with `extensions` is available for specific use cases. It contains the following APIs:
@@ -86,13 +98,13 @@ Can you think of more? Let's discuss in the issues section!
8698

8799
```kotlin
88100
junitPlatform {
89-
instrumentationTests.includeExtensions.set(true)
101+
instrumentationTests.includeExtensions = true
90102
}
91103
```
92104

93105
### Jetpack Compose
94106

95-
To test `@Composable` functions on devices compatible with the JUnit Framework,
107+
To test `@Composable` functions on devices compatible with modern JUnit,
96108
enable support for instrumentation tests as described above. Then add the Compose test dependency
97109
to your `androidTestImplementation` configuration and the plugin will autoconfigure JUnit 5 Compose support for you.
98110

@@ -117,7 +129,7 @@ when it sets up the artifacts automatically. However, it is possible to choose a
117129

118130
```kotlin
119131
junitPlatform {
120-
instrumentationTests.version.set("${instrumentationVersion}")
132+
instrumentationTests.version = "${instrumentationVersion}"
121133
}
122134
```
123135

@@ -132,7 +144,7 @@ The following list is an aggregation of pending feature requests:
132144

133145
## Support for @Rules
134146

135-
Since the JUnit Framework has replaced the `@Rule` mechanism with the concept of an `Extension`,
147+
Since JUnit has replaced the `@Rule` mechanism with the concept of an `Extension` in version 5,
136148
the following artifacts help bridge the gap until Android officially transitions, if ever.
137149

138150
### InstantExecutorExtension
@@ -191,8 +203,8 @@ limitations under the License.
191203

192204
See also the [full License text](LICENSE).
193205

194-
[junit-framework-github]: https://github.com/junit-team/junit-framework
195-
[junit-framework-guide]: https://docs.junit.org
206+
[junit-github]: https://github.com/junit-team/junit-framework
207+
[junit-guide]: https://docs.junit.org
196208
[circleci]: https://circleci.com/gh/mannodermaus/android-junit-framework
197209
[sonatyperepo]: https://central.sonatype.com/repository/maven-snapshots
198210
[sampletests]: instrumentation/sample

build-logic/src/main/kotlin/Environment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ object Artifacts {
106106
platform = Java,
107107
groupId = "de.mannodermaus.gradle.plugins",
108108
artifactId = "android-junit5",
109-
currentVersion = "2.0.0",
110-
latestStableVersion = "1.14.0.0",
109+
currentVersion = "2.0.1-SNAPSHOT",
110+
latestStableVersion = "2.0.0",
111111
description = "Unit Testing with the JUnit Framework for Android."
112112
)
113113

plugin/.idea/runConfigurations/Generate_README_md.xml

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)