Skip to content

Commit b732055

Browse files
committed
Explore JUnit 6.0.0 (#389)
* Update to Java 17, Kotlin 2.2, JUnit 6.0.0 * Update instrumentation to JUnit 6.0.0, raising its minimum API level to 35 * Update Firebase Test Lab devices * Snapshot version update * Update readme for testing * Tweak test conditions * apiDump * Only 1 FTL device # Conflicts: # README.md # build-logic/src/main/kotlin/Dependencies.kt # build-logic/src/main/kotlin/Environment.kt # instrumentation/CHANGELOG.md
1 parent 7c9fd63 commit b732055

38 files changed

+192
-168
lines changed

.circleci/config.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defaults: &defaults
33
working_directory: ~/root/project
44
resource_class: large
55
docker:
6-
- image: cimg/android:2023.04.1
6+
- image: cimg/android:2025.09.1
77
environment:
88
GRADLE_OPTS: -Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.daemon=false -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false
99

@@ -68,8 +68,7 @@ jobs:
6868
--test instrumentation/core/build/outputs/apk/androidTest/debug/core-debug-androidTest.apk \
6969
--environment-variables runnerBuilder=de.mannodermaus.junit5.AndroidJUnit5Builder \
7070
--test-runner-class androidx.test.runner.AndroidJUnitRunner \
71-
--device model=redfin,version=30,locale=en_US,orientation=portrait \
72-
--device model=oriole,version=33,locale=en_US,orientation=portrait \
71+
--device model=pa3q,version=35,locale=en_US,orientation=portrait \
7372
--results-bucket cloud-test-${GOOGLE_PROJECT_ID} \
7473
--timeout 15m
7574
- run:

README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
To update the content of this README, please apply modifications
44
to `README.md.template` instead, and run the `generateReadme` task from Gradle.
55
-->
6-
# <img src=".images/logo.png" align="right" width="100">android-junit5 [![CircleCI](https://circleci.com/gh/mannodermaus/android-junit5/tree/main.svg?style=svg)][circleci]
6+
# <img src=".images/logo.png" align="right" width="100">JUnit Jupiter for Android [![CircleCI](https://circleci.com/gh/mannodermaus/android-junit5/tree/main.svg?style=svg)][circleci]
77

8-
A Gradle plugin that allows for the execution of [JUnit 5][junit5gh] tests in Android environments using **Android Gradle Plugin 8.2 or later.**
8+
A Gradle plugin that allows for the execution of [JUnit Jupiter][junitgh] tests in Android environments using **Android Gradle Plugin 8.2 or later.**
99

1010
## How?
1111

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

14-
Instructions on how to write tests with the JUnit 5 framework can be found [in their User Guide][junit5ug]. To get a first look at its features, a small showcase project can be found [here][sampletests].
14+
Instructions on how to write tests with the JUnit framework can be found [in their User Guide][junitug]. To get a first look at its features, a small showcase project can be found [here][sampletests].
1515

1616
## Setup
1717

@@ -27,15 +27,15 @@ To get started, declare the plugin in your `app` module's build script alongside
2727

2828
dependencies {
2929
// (Required) Writing and executing Unit Tests on the JUnit Platform
30-
testImplementation("org.junit.jupiter:junit-jupiter-api:5.14.0")
31-
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.14.0")
30+
testImplementation("org.junit.jupiter:junit-jupiter-api:6.0.0")
31+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:6.0.0")
3232

3333
// (Optional) If you need "Parameterized Tests"
34-
testImplementation("org.junit.jupiter:junit-jupiter-params:5.14.0")
34+
testImplementation("org.junit.jupiter:junit-jupiter-params:6.0.0")
3535

3636
// (Optional) If you also have JUnit 4-based tests
3737
testImplementation("junit:junit:4.13.2")
38-
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.14.0")
38+
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:6.0.0")
3939
}
4040
```
4141
</details>
@@ -50,15 +50,15 @@ To get started, declare the plugin in your `app` module's build script alongside
5050
5151
dependencies {
5252
// (Required) Writing and executing Unit Tests on the JUnit Platform
53-
testImplementation "org.junit.jupiter:junit-jupiter-api:5.14.0"
54-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.14.0"
53+
testImplementation "org.junit.jupiter:junit-jupiter-api:6.0.0"
54+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:6.0.0"
5555
5656
// (Optional) If you need "Parameterized Tests"
57-
testImplementation "org.junit.jupiter:junit-jupiter-params:5.14.0"
57+
testImplementation "org.junit.jupiter:junit-jupiter-params:6.0.0"
5858
5959
// (Optional) If you also have JUnit 4-based tests
6060
testImplementation "junit:junit:4.13.2"
61-
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.14.0"
61+
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:6.0.0"
6262
}
6363
```
6464
</details>
@@ -115,16 +115,16 @@ The latest version of this plugin requires:
115115

116116
## Instrumentation Test Support
117117

118-
You can use JUnit 5 to run instrumentation tests on emulators and physical devices, too. Because the framework is built on Java 8 from the ground up, these instrumentation tests will only run on devices running Android 8.0 (API 26) or newer – older phones will skip the execution of these tests completely, marking them as "ignored".
118+
You can use JUnit Jupiter to run instrumentation tests on emulators and physical devices, too. Because the framework is built on Java 17 from the ground up, these instrumentation tests will only run on devices running Android 15 (API 35) or newer – older phones will skip the execution of these tests completely, marking them as "ignored".
119119

120-
Before you can write instrumentation tests with JUnit Jupiter, make sure that your module is using the `androidx.test.runner.AndroidJUnitRunner` (or a subclass of it) as its `testInstrumentationRunner`. Then, simply add a dependency on `junit-jupiter-api` to the `androidTestImplementation` configuration in your build script and the plugin will automatically configure JUnit 5 tests for you:
120+
Before you can write instrumentation tests with JUnit Jupiter, make sure that your module is using the `androidx.test.runner.AndroidJUnitRunner` (or a subclass of it) as its `testInstrumentationRunner`. Then, simply add a dependency on `junit-jupiter-api` to the `androidTestImplementation` configuration in your build script and the plugin will automatically configure JUnit Jupiter tests for you:
121121

122122
<details open>
123123
<summary>Kotlin</summary>
124124

125125
```kotlin
126126
dependencies {
127-
androidTestImplementation("org.junit.jupiter:junit-jupiter-api:5.14.0")
127+
androidTestImplementation("org.junit.jupiter:junit-jupiter-api:6.0.0")
128128
}
129129
```
130130
</details>
@@ -134,12 +134,12 @@ Before you can write instrumentation tests with JUnit Jupiter, make sure that yo
134134

135135
```groovy
136136
dependencies {
137-
androidTestImplementation "org.junit.jupiter:junit-jupiter-api:5.14.0"
137+
androidTestImplementation "org.junit.jupiter:junit-jupiter-api:6.0.0"
138138
}
139139
```
140140
</details>
141141

142-
By enabling JUnit 5 for instrumentation tests, you will gain access to `ActivityScenarioExtension` (among other things), which helps with the orchestration of `Activity` classes. Check [the wiki][wiki-home] for more info.
142+
By enabling JUnit Jupiter for instrumentation tests, you will gain access to `ActivityScenarioExtension` (among other things), which helps with the orchestration of `Activity` classes. Check [the wiki][wiki-home] for more info.
143143

144144
### Extensions
145145

@@ -172,9 +172,9 @@ Can you think of more? Let's discuss in the issues section!
172172

173173
### Jetpack Compose
174174

175-
To test `@Composable` functions on device with JUnit 5, first enable support for instrumentation tests as described above.
175+
To test `@Composable` functions on device with JUnit Jupiter, first enable support for instrumentation tests as described above.
176176
Then, add the Compose test dependency to your `androidTestImplementation` configuration
177-
and the plugin will autoconfigure JUnit 5 Compose support for you!
177+
and the plugin will autoconfigure JUnit Jupiter Compose support for you!
178178

179179
<details open>
180180
<summary>Kotlin</summary>
@@ -204,7 +204,7 @@ and the plugin will autoconfigure JUnit 5 Compose support for you!
204204
```
205205
</details>
206206

207-
[The wiki][wiki-home] includes a section on how to test your Composables with JUnit 5.
207+
[The wiki][wiki-home] includes a section on how to test your Composables with JUnit Jupiter.
208208

209209
### Override the version of instrumentation test libraries
210210

@@ -233,19 +233,19 @@ when it sets up the artifacts automatically. However, it is possible to choose a
233233

234234
## Official Support
235235

236-
At this time, Google hasn't shared any immediate plans to bring first-party support for JUnit 5 to Android. The following list is an aggregation of pending feature requests:
236+
At this time, Google hasn't shared any immediate plans to bring first-party support for JUnit Jupiter to Android. The following list is an aggregation of pending feature requests:
237237

238238
- [InstantTaskExecutorRule uses @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -- why? (issuetracker.google.com)](https://issuetracker.google.com/u/0/issues/79189568)
239239
- [Add support for JUnit 5 (issuetracker.google.com)](https://issuetracker.google.com/issues/127100532)
240240
- [JUnit 5 support (github.com/android/android-test)](https://github.com/android/android-test/issues/224)
241241

242242
## Support for @Rules
243243

244-
Since JUnit 5 has replaced the `@Rule` mechanism with Extensions, the following artifacts help bridge the gap until Android officially transitions to JUnit 5.
244+
Since JUnit Jupiter has replaced the `@Rule` mechanism with Extensions, the following artifacts help bridge the gap until Android officially transitions to JUnit Jupiter.
245245

246246
### InstantExecutorExtension
247247

248-
Replaces `InstantTaskExecutorRule` in JUnit 5.
248+
Replaces `InstantTaskExecutorRule` in JUnit Jupiter.
249249

250250
<details>
251251
<summary>Kotlin</summary>
@@ -274,7 +274,7 @@ For more details see [instant-task-executor-extension](https://github.com/nebosk
274274
This repository contains multiple modules, divided into two sub-projects. The repository's root directory contains build logic shared across the sub-projects, which in turn use symlinks to connect to the common build scripts in their parent folder.
275275

276276
- `instrumentation`: The root folder for Android-based modules, namely the instrumentation libraries & a sample application. After cloning, open this project in Android Studio.
277-
- `plugin`: The root folder for Java-based modules, namely the Gradle plugin for JUnit 5 on Android, as well as its test module. After cloning, open this project in IntelliJ IDEA.
277+
- `plugin`: The root folder for Java-based modules, namely the Gradle plugin for JUnit Jupiter on Android, as well as its test module. After cloning, open this project in IntelliJ IDEA.
278278

279279
## Plugin Compatibility Map
280280

@@ -283,7 +283,7 @@ refer to the table below to find a suitable alternative version. Note that **no
283283
legacy versions**, so please consider upgrading to at least Android Gradle Plugin 8.2
284284
before filing an issue with the latest one.
285285

286-
|Your AGP Version|Suggested JUnit5 Plugin Version|
286+
|Your AGP Version|Suggested Plugin Version|
287287
|---|---|
288288
|`>= 8.2.0`|`1.14.0.0`|
289289
|`8.0.0` - `8.1.4`|`1.12.2.0`|
@@ -312,8 +312,8 @@ limitations under the License.
312312

313313
See also the [full License text](LICENSE).
314314

315-
[junit5gh]: https://github.com/junit-team/junit5
316-
[junit5ug]: https://junit.org/junit5/docs/current/user-guide
315+
[junitgh]: https://github.com/junit-team/junit5
316+
[junitug]: https://junit.org/junit5/docs/current/user-guide
317317
[circleci]: https://circleci.com/gh/mannodermaus/android-junit5
318318
[sonatyperepo]: https://central.sonatype.com/repository/maven-snapshots
319319
[sampletests]: instrumentation/sample

README.md.template

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# <img src=".images/logo.png" align="right" width="100">android-junit5 [![CircleCI](https://circleci.com/gh/mannodermaus/android-junit5/tree/main.svg?style=svg)][circleci]
1+
# <img src=".images/logo.png" align="right" width="100">JUnit Jupiter for Android [![CircleCI](https://circleci.com/gh/mannodermaus/android-junit5/tree/main.svg?style=svg)][circleci]
22

3-
A Gradle plugin that allows for the execution of [JUnit 5][junit5gh] tests in Android environments using **Android Gradle Plugin ${constants.minimumRequiredAgpVersion} or later.**
3+
A Gradle plugin that allows for the execution of [JUnit Jupiter][junitgh] tests in Android environments using **Android Gradle Plugin ${constants.minimumRequiredAgpVersion} or later.**
44

55
## How?
66

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

9-
Instructions on how to write tests with the JUnit 5 framework can be found [in their User Guide][junit5ug]. To get a first look at its features, a small showcase project can be found [here][sampletests].
9+
Instructions on how to write tests with the JUnit framework can be found [in their User Guide][junitug]. To get a first look at its features, a small showcase project can be found [here][sampletests].
1010

1111
## Setup
1212

@@ -110,9 +110,9 @@ The latest version of this plugin requires:
110110

111111
## Instrumentation Test Support
112112

113-
You can use JUnit 5 to run instrumentation tests on emulators and physical devices, too. Because the framework is built on Java 8 from the ground up, these instrumentation tests will only run on devices running Android 8.0 (API 26) or newer – older phones will skip the execution of these tests completely, marking them as "ignored".
113+
You can use JUnit Jupiter to run instrumentation tests on emulators and physical devices, too. Because the framework is built on Java 17 from the ground up, these instrumentation tests will only run on devices running Android 15 (API 35) or newer – older phones will skip the execution of these tests completely, marking them as "ignored".
114114

115-
Before you can write instrumentation tests with JUnit Jupiter, make sure that your module is using the `androidx.test.runner.AndroidJUnitRunner` (or a subclass of it) as its `testInstrumentationRunner`. Then, simply add a dependency on `junit-jupiter-api` to the `androidTestImplementation` configuration in your build script and the plugin will automatically configure JUnit 5 tests for you:
115+
Before you can write instrumentation tests with JUnit Jupiter, make sure that your module is using the `androidx.test.runner.AndroidJUnitRunner` (or a subclass of it) as its `testInstrumentationRunner`. Then, simply add a dependency on `junit-jupiter-api` to the `androidTestImplementation` configuration in your build script and the plugin will automatically configure JUnit Jupiter tests for you:
116116

117117
<details open>
118118
<summary>Kotlin</summary>
@@ -134,7 +134,7 @@ Before you can write instrumentation tests with JUnit Jupiter, make sure that yo
134134
```
135135
</details>
136136

137-
By enabling JUnit 5 for instrumentation tests, you will gain access to `ActivityScenarioExtension` (among other things), which helps with the orchestration of `Activity` classes. Check [the wiki][wiki-home] for more info.
137+
By enabling JUnit Jupiter for instrumentation tests, you will gain access to `ActivityScenarioExtension` (among other things), which helps with the orchestration of `Activity` classes. Check [the wiki][wiki-home] for more info.
138138

139139
### Extensions
140140

@@ -167,9 +167,9 @@ Can you think of more? Let's discuss in the issues section!
167167

168168
### Jetpack Compose
169169

170-
To test `@Composable` functions on device with JUnit 5, first enable support for instrumentation tests as described above.
170+
To test `@Composable` functions on device with JUnit Jupiter, first enable support for instrumentation tests as described above.
171171
Then, add the Compose test dependency to your `androidTestImplementation` configuration
172-
and the plugin will autoconfigure JUnit 5 Compose support for you!
172+
and the plugin will autoconfigure JUnit Jupiter Compose support for you!
173173

174174
<details open>
175175
<summary>Kotlin</summary>
@@ -199,7 +199,7 @@ and the plugin will autoconfigure JUnit 5 Compose support for you!
199199
```
200200
</details>
201201

202-
[The wiki][wiki-home] includes a section on how to test your Composables with JUnit 5.
202+
[The wiki][wiki-home] includes a section on how to test your Composables with JUnit Jupiter.
203203

204204
### Override the version of instrumentation test libraries
205205

@@ -228,19 +228,19 @@ when it sets up the artifacts automatically. However, it is possible to choose a
228228

229229
## Official Support
230230

231-
At this time, Google hasn't shared any immediate plans to bring first-party support for JUnit 5 to Android. The following list is an aggregation of pending feature requests:
231+
At this time, Google hasn't shared any immediate plans to bring first-party support for JUnit Jupiter to Android. The following list is an aggregation of pending feature requests:
232232

233233
- [InstantTaskExecutorRule uses @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -- why? (issuetracker.google.com)](https://issuetracker.google.com/u/0/issues/79189568)
234234
- [Add support for JUnit 5 (issuetracker.google.com)](https://issuetracker.google.com/issues/127100532)
235235
- [JUnit 5 support (github.com/android/android-test)](https://github.com/android/android-test/issues/224)
236236

237237
## Support for @Rules
238238

239-
Since JUnit 5 has replaced the `@Rule` mechanism with Extensions, the following artifacts help bridge the gap until Android officially transitions to JUnit 5.
239+
Since JUnit Jupiter has replaced the `@Rule` mechanism with Extensions, the following artifacts help bridge the gap until Android officially transitions to JUnit Jupiter.
240240

241241
### InstantExecutorExtension
242242

243-
Replaces `InstantTaskExecutorRule` in JUnit 5.
243+
Replaces `InstantTaskExecutorRule` in JUnit Jupiter.
244244

245245
<details>
246246
<summary>Kotlin</summary>
@@ -269,7 +269,7 @@ For more details see [instant-task-executor-extension](https://github.com/nebosk
269269
This repository contains multiple modules, divided into two sub-projects. The repository's root directory contains build logic shared across the sub-projects, which in turn use symlinks to connect to the common build scripts in their parent folder.
270270

271271
- `instrumentation`: The root folder for Android-based modules, namely the instrumentation libraries & a sample application. After cloning, open this project in Android Studio.
272-
- `plugin`: The root folder for Java-based modules, namely the Gradle plugin for JUnit 5 on Android, as well as its test module. After cloning, open this project in IntelliJ IDEA.
272+
- `plugin`: The root folder for Java-based modules, namely the Gradle plugin for JUnit Jupiter on Android, as well as its test module. After cloning, open this project in IntelliJ IDEA.
273273

274274
## Plugin Compatibility Map
275275

@@ -278,7 +278,7 @@ refer to the table below to find a suitable alternative version. Note that **no
278278
legacy versions**, so please consider upgrading to at least Android Gradle Plugin ${constants.minimumRequiredAgpVersion}
279279
before filing an issue with the latest one.
280280

281-
|Your AGP Version|Suggested JUnit5 Plugin Version|
281+
|Your AGP Version|Suggested Plugin Version|
282282
|---|---|
283283
|`>= 8.2.0`|`${pluginVersion}`|
284284
|`8.0.0` - `8.1.4`|`1.12.2.0`|
@@ -307,8 +307,8 @@ limitations under the License.
307307

308308
See also the [full License text](LICENSE).
309309

310-
[junit5gh]: https://github.com/junit-team/junit5
311-
[junit5ug]: https://junit.org/junit5/docs/current/user-guide
310+
[junitgh]: https://github.com/junit-team/junit5
311+
[junitug]: https://junit.org/junit5/docs/current/user-guide
312312
[circleci]: https://circleci.com/gh/mannodermaus/android-junit5
313313
[sonatyperepo]: https://central.sonatype.com/repository/maven-snapshots
314314
[sampletests]: instrumentation/sample

0 commit comments

Comments
 (0)