{"id":13428812,"url":"https://github.com/mannodermaus/android-junit5","last_synced_at":"2025-12-24T23:50:12.357Z","repository":{"id":38814499,"uuid":"69637233","full_name":"mannodermaus/android-junit5","owner":"mannodermaus","description":"Testing with JUnit 5 for Android.","archived":false,"fork":false,"pushed_at":"2024-05-22T14:21:06.000Z","size":2642,"stargazers_count":834,"open_issues_count":9,"forks_count":52,"subscribers_count":17,"default_branch":"main","last_synced_at":"2024-05-22T14:59:24.572Z","etag":null,"topics":["android","gradle-plugin","junit","junit5","unittesting"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mannodermaus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-30T05:40:48.000Z","updated_at":"2024-06-06T19:34:11.912Z","dependencies_parsed_at":"2023-02-10T17:30:19.317Z","dependency_job_id":"fdabc68e-d3d8-4514-b937-6f92ab012369","html_url":"https://github.com/mannodermaus/android-junit5","commit_stats":null,"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mannodermaus%2Fandroid-junit5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mannodermaus%2Fandroid-junit5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mannodermaus%2Fandroid-junit5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mannodermaus%2Fandroid-junit5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mannodermaus","download_url":"https://codeload.github.com/mannodermaus/android-junit5/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243815575,"owners_count":20352194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","gradle-plugin","junit","junit5","unittesting"],"created_at":"2024-07-31T01:01:05.761Z","updated_at":"2025-12-24T23:50:12.350Z","avatar_url":"https://github.com/mannodermaus.png","language":"Kotlin","readme":"\u003c!--\n  This file was automatically generated by Gradle. Do not modify.\n  To update the content of this README, please apply modifications\n  to `README.md.template` instead, and run the `generateReadme` task from Gradle.\n--\u003e\n# \u003cimg src=\".images/logo.png\" align=\"right\" width=\"100\"\u003eandroid-junit5 [![CircleCI](https://circleci.com/gh/mannodermaus/android-junit5/tree/main.svg?style=svg)][circleci]\n\nA Gradle plugin that allows for the execution of [JUnit 5][junit5gh] tests in Android environments using **Android Gradle Plugin 8.2 or later.**\n\n## How?\n\nThis 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.\n\nInstructions 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].\n\n## Setup\n\nTo get started, declare the plugin in your `app` module's build script alongside the latest version. Snapshots of the development version are available through [Sonatype's `snapshots` repository][sonatyperepo].\n\n\u003cdetails open\u003e\n  \u003csummary\u003eKotlin\u003c/summary\u003e\n\n  ```kotlin\n  plugins {\n    id(\"de.mannodermaus.android-junit5\") version \"1.14.0.0\"\n  }\n\n  dependencies {\n    // (Required) Writing and executing Unit Tests on the JUnit Platform\n    testImplementation(\"org.junit.jupiter:junit-jupiter-api:5.14.0\")\n    testRuntimeOnly(\"org.junit.jupiter:junit-jupiter-engine:5.14.0\")\n\n    // (Optional) If you need \"Parameterized Tests\"\n    testImplementation(\"org.junit.jupiter:junit-jupiter-params:5.14.0\")\n\n    // (Optional) If you also have JUnit 4-based tests\n    testImplementation(\"junit:junit:4.13.2\")\n    testRuntimeOnly(\"org.junit.vintage:junit-vintage-engine:5.14.0\")\n  }\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eGroovy\u003c/summary\u003e\n\n  ```groovy\n  plugins {\n    id \"de.mannodermaus.android-junit5\" version \"1.14.0.0\"\n  }\n\n  dependencies {\n    // (Required) Writing and executing Unit Tests on the JUnit Platform\n    testImplementation \"org.junit.jupiter:junit-jupiter-api:5.14.0\"\n    testRuntimeOnly \"org.junit.jupiter:junit-jupiter-engine:5.14.0\"\n\n    // (Optional) If you need \"Parameterized Tests\"\n    testImplementation \"org.junit.jupiter:junit-jupiter-params:5.14.0\"\n\n    // (Optional) If you also have JUnit 4-based tests\n    testImplementation \"junit:junit:4.13.2\"\n    testRuntimeOnly \"org.junit.vintage:junit-vintage-engine:5.14.0\"\n  }\n  ```\n\u003c/details\u003e\n\n\u003cbr/\u003e\n\n### Alternative: Legacy DSL\n\nIf you prefer to use the legacy way to declare the dependency instead, remove the `version()` block from above and declare the plugin in your _root project's build script_ like so:\n\n\u003cdetails\u003e\n  \u003csummary\u003eKotlin\u003c/summary\u003e\n\n  ```kotlin\n  // In the root project's build.gradle.kts:\n  buildscript {\n    dependencies {\n      classpath(\"de.mannodermaus.gradle.plugins:android-junit5:1.14.0.0\")\n    }\n  }\n\n  // In the app module's build.gradle.kts:\n  plugins {\n    id(\"de.mannodermaus.android-junit5\")\n  }\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eGroovy\u003c/summary\u003e\n\n  ```groovy\n  // In the root project's build.gradle:\n  buildscript {\n    dependencies {\n      classpath \"de.mannodermaus.gradle.plugins:android-junit5:1.14.0.0\"\n    }\n  }\n\n  // In the app module's build.gradle:\n  apply plugin: \"de.mannodermaus.android-junit5\"\n  ```\n\u003c/details\u003e\n\n\u003cbr/\u003e\n\nMore information on Getting Started can be found [on the wiki][wiki-gettingstarted].\n\n## Requirements\n\nThe latest version of this plugin requires:\n* Android Gradle Plugin `8.2` or above\n* Gradle `8.2` or above\n\n## Instrumentation Test Support\n\nYou 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\".\n\nBefore 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:\n\n\u003cdetails open\u003e\n  \u003csummary\u003eKotlin\u003c/summary\u003e\n  \n  ```kotlin\n  dependencies {\n    androidTestImplementation(\"org.junit.jupiter:junit-jupiter-api:5.14.0\")\n  }\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eGroovy\u003c/summary\u003e\n\n  ```groovy\n  dependencies {\n    androidTestImplementation \"org.junit.jupiter:junit-jupiter-api:5.14.0\"\n  }\n  ```\n\u003c/details\u003e\n\nBy 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.\n\n### Extensions\n\nAn optional artifact with more helper extensions is available for specific use cases.\nIt contains the following APIs:\n\n- `GrantPermissionExtension` for granting permissions before each test\n\nCan you think of more? Let's discuss in the issues section!\n\n\u003cdetails open\u003e\n  \u003csummary\u003eKotlin\u003c/summary\u003e\n\n  ```kotlin\n  junitPlatform {\n    instrumentationTests.includeExtensions.set(true)\n  }\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eGroovy\u003c/summary\u003e\n\n  ```groovy\n  junitPlatform {\n    instrumentationTests.includeExtensions.set(true)\n  }\n  ```\n\u003c/details\u003e\n\n### Jetpack Compose\n\nTo test `@Composable` functions on device with JUnit 5, first enable support for instrumentation tests as described above.\nThen, add the Compose test dependency to your `androidTestImplementation` configuration\nand the plugin will autoconfigure JUnit 5 Compose support for you!\n\n\u003cdetails open\u003e\n  \u003csummary\u003eKotlin\u003c/summary\u003e\n  \n  ```kotlin\n  dependencies {\n    // Compose test framework\n    androidTestImplementation(\"androidx.compose.ui:ui-test-android:$compose_version\")\n\n    // Needed for createComposeExtension() and createAndroidComposeExtension()\n    debugImplementation(\"androidx.compose.ui:ui-test-manifest:$compose_version\")\n  }\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eGroovy\u003c/summary\u003e\n\n  ```groovy\n  dependencies {\n    // Compose test framework\n    androidTestImplementation \"androidx.compose.ui:ui-test-android:$compose_version\"\n\n    // Needed for createComposeExtension() and createAndroidComposeExtension()\n    debugImplementation \"androidx.compose.ui:ui-test-manifest:$compose_version\"\n  }\n  ```\n\u003c/details\u003e\n\n[The wiki][wiki-home] includes a section on how to test your Composables with JUnit 5.\n\n### Override the version of instrumentation test libraries\n\nBy default, the plugin will make sure to use a compatible version of the instrumentation test libraries\nwhen it sets up the artifacts automatically. However, it is possible to choose a custom version instead via its DSL:\n\n\u003cdetails open\u003e\n  \u003csummary\u003eKotlin\u003c/summary\u003e\n\n  ```kotlin\n  junitPlatform {\n    instrumentationTests.version.set(\"1.9.0\")\n  }\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eGroovy\u003c/summary\u003e\n\n  ```groovy\n  junitPlatform {\n    instrumentationTests.version.set(\"1.9.0\")\n  }\n  ```\n\u003c/details\u003e\n\n## Official Support\n\nAt 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:\n\n- [InstantTaskExecutorRule uses @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -- why? (issuetracker.google.com)](https://issuetracker.google.com/u/0/issues/79189568)\n- [Add support for JUnit 5 (issuetracker.google.com)](https://issuetracker.google.com/issues/127100532)\n- [JUnit 5 support (github.com/android/android-test)](https://github.com/android/android-test/issues/224)\n\n## Support for @Rules\n\nSince JUnit 5 has replaced the `@Rule` mechanism with Extensions, the following artifacts help bridge the gap until Android officially transitions to JUnit 5.\n\n### InstantExecutorExtension\n\nReplaces `InstantTaskExecutorRule` in JUnit 5.\n\n\u003cdetails\u003e\n  \u003csummary\u003eKotlin\u003c/summary\u003e\n\n  ```kotlin\n  dependencies {\n      testImplementation(\"io.github.neboskreb:instant-task-executor-extension:1.0.0\")\n  }\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eGroovy\u003c/summary\u003e\n\n  ```groovy\n  dependencies {\n      testImplementation 'io.github.neboskreb:instant-task-executor-extension:1.0.0'\n  }\n  ```\n\u003c/details\u003e\n\nFor more details see [instant-task-executor-extension](https://github.com/neboskreb/instant-task-executor-extension) on GitHub.\n\n## Building Locally\n\nThis 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.\n\n- `instrumentation`: The root folder for Android-based modules, namely the instrumentation libraries \u0026 a sample application. After cloning, open this project in Android Studio.\n- `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.\n\n## Plugin Compatibility Map\n\nFor users that cannot match the current minimum version requirement of the Android Gradle Plugin requested by this plugin,\nrefer to the table below to find a suitable alternative version. Note that **no active development will go into these\nlegacy versions**, so please consider upgrading to at least Android Gradle Plugin 8.2\nbefore filing an issue with the latest one.\n\n|Your AGP Version|Suggested JUnit5 Plugin Version|\n|---|---|\n|`\u003e= 8.2.0`|`1.14.0.0`|\n|`8.0.0` - `8.1.4`|`1.12.2.0`|\n|`7.0.0` - `7.4.2`|`1.10.0.0`|\n|`4.0.0` - `4.2.2`|`1.8.2.1`|\n|`3.5.0` - `3.6.4`|`1.7.1.1`|\n|`\u003c 3.5.0`|none; you should **really** update your build env, bro|\n\n## License\n\n```\nCopyright 2017-2025 Marcel Schnelle\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\nSee also the [full License text](LICENSE).\n\n [junit5gh]: https://github.com/junit-team/junit5\n [junit5ug]: https://junit.org/junit5/docs/current/user-guide\n [circleci]: https://circleci.com/gh/mannodermaus/android-junit5\n [sonatyperepo]: https://central.sonatype.com/repository/maven-snapshots\n [sampletests]: instrumentation/sample\n [wiki-home]: https://github.com/mannodermaus/android-junit5/wiki\n [wiki-dsl]: https://github.com/mannodermaus/android-junit5/wiki/Configuration\n [wiki-gettingstarted]: https://github.com/mannodermaus/android-junit5/wiki/Getting-Started\n","funding_links":[],"categories":["Libraries","Kotlin"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmannodermaus%2Fandroid-junit5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmannodermaus%2Fandroid-junit5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmannodermaus%2Fandroid-junit5/lists"}