{"id":27598514,"url":"https://github.com/bjoernq/unmock-plugin","last_synced_at":"2025-10-03T23:36:01.896Z","repository":{"id":27361767,"uuid":"30837165","full_name":"bjoernQ/unmock-plugin","owner":"bjoernQ","description":"Gradle plugin to be used in combination with the new unit testing feature of the Gradle Plugin / Android Studio to use real classes for e.g. SparseArray.","archived":false,"fork":false,"pushed_at":"2024-11-16T13:31:26.000Z","size":331,"stargazers_count":326,"open_issues_count":12,"forks_count":22,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-22T14:14:37.617Z","etag":null,"topics":["android","gradle-plugin","mocking","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"Java","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/bjoernQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2015-02-15T18:35:15.000Z","updated_at":"2025-04-11T11:13:25.000Z","dependencies_parsed_at":"2025-04-02T09:33:18.251Z","dependency_job_id":"6df891d6-b92a-4b89-9adb-ede83d984feb","html_url":"https://github.com/bjoernQ/unmock-plugin","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoernQ%2Funmock-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoernQ%2Funmock-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoernQ%2Funmock-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoernQ%2Funmock-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjoernQ","download_url":"https://codeload.github.com/bjoernQ/unmock-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250255772,"owners_count":21400410,"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","mocking","unit-testing"],"created_at":"2025-04-22T14:14:44.788Z","updated_at":"2025-10-03T23:35:56.848Z","avatar_url":"https://github.com/bjoernQ.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.bjoernq/unmockplugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.bjoernq/unmockplugin) [![Apache License](http://img.shields.io/badge/license-Apache%20License%202.0-lightgrey.svg)](http://choosealicense.com/licenses/apache-2.0/)\n\n# Android Unmock Gradle Plugin\n\n## Purpose\n\nThis is a super simple plugin to be used in combination with the new unit testing feature of the Gradle Plugin / Android Studio. ( http://tools.android.com/tech-docs/unit-testing-support )\n\nIt tries to solve the problem that you have to mock each and every Android SDK class (even SparseArray, TextUtils etc.) by allowing you to use selected classes from a real Android-Jarfile.\n\n## How to use\n\nAdd the plugin to your buildscript dependencies and make sure to use the maven central repository:\n\n```groovy\nbuildscript {\n    repositories {\n        mavenCentral()\n    }\n    \n    dependencies {\n        classpath \"com.github.bjoernq:unmockplugin:${unmockpluginVersion}\"\n    }\n}\n```\n\nPlease note: Versions prior to 0.7.6 are not available on Maven Central.\n\nAnd this to the module's build script:\n\n```groovy\napply plugin: 'de.mobilej.unmock'\n```\n\nAdditionally you have to configure which classes to use and where to get the real Android.jar from. e.g:\n\n```groovy\nunMock {\n    keep \"android.widget.BaseAdapter\"\n    keep \"android.widget.ArrayAdapter\"\n    keep \"android.os.Bundle\"\n    keepStartingWith \"android.database.MatrixCursor\"\n    keep \"android.database.AbstractCursor\"\n    keep \"android.database.CrossProcessCursor\"\n    keepStartingWith \"android.text.TextUtils\"\n    keepStartingWith \"android.util.\"\n    keepStartingWith \"android.text.\"\n    keepStartingWith \"android.content.ContentValues\"\n    keepStartingWith \"android.content.ComponentName\"\n    keepStartingWith \"android.content.ContentUris\"\n    keepStartingWith \"android.content.ContentProviderOperation\"\n    keepStartingWith \"android.content.ContentProviderResult\"\n    keepStartingWith \"android.content.UriMatcher\"\n    keepStartingWith \"android.content.Intent\"\n    keep \"android.location.Location\"\n    keepStartingWith \"android.content.res.Configuration\"\n    keepStartingWith \"org.\"\n    keepStartingWith \"libcore.\"\n    keepStartingWith \"com.android.internal.R\"\n    keepStartingWith \"com.android.internal.util.\"\n    keep \"android.net.Uri\"\n\n    keepAndRename \"java.nio.charset.Charsets\" to \"xjava.nio.charset.Charsets\"\n}\n\ndependencies {\n    // dependency to android-all to use\n    unmock 'org.robolectric:android-all:4.3_r2-robolectric-0'\n}\n\n```\n\n|Statement|Description|\n|-------|-----------|\n|keep|keeps the specified class (and it's possibly present inner classes)|\n|keepStartingWith|keeps every class which FQN starts with the given string|\n|keepAndRename|let you keep a class while renaming it (e.g. needed for classes in the \"java\" top-level package since these are only allowed to be loaded from the boot classpath)|\n|delegateClass|every method (and constructor) in the given class is delegated to de.mobilej.ABridge. Makes it easier to mock things in a framework class you inherit from|\n\nThat's it!\n\nHave a look at the example contained in this repository for more details.\n\nStarting from version 0.3.5 you can leave out the configuration closure which will result using defaults (which are shown in the example above).\n\nIf you use any of the keep statements the default configuration will be cleared. (So your own configuration is not adding but replaces the default).\n\nIf you don't configure the unmock dependency the plugin will use `org.robolectric:android-all:4.3_r2-robolectric-0`\n\n## Versions\n\n|Version|Description|\n|-------|-----------|\n|0.1.0|initial public release|\n|0.1.1|added the '-' matching|\n|0.1.2|fixed a bug preventing the plugin to work correctly on Windows systems|\n|0.1.3|the binary is targeting Java 1.7, again|\n|0.2.0|support class renaming, rebuild jar if build file changed|\n|0.3.0|use Gradle way of upToDate check, have a DSL for the configuration|\n|0.3.1|compile with Gradle 2.4|\n|0.3.2|lib-sample and some bugfixes (frozen class problem)|\n|0.3.3|Android Gradle Plugin 1.3.0 compatibility|\n|0.3.5|Use default config if no configuration closure is given|\n|0.3.6|Optionally you can specify a directory to download the all-android.jar to|\n|0.4.0|Support for \"delegateClass\" added|\n|0.5.0|ABridge now includes callByte, callDouble and callFloat, this _might_ break tests that rely on ABrdige.callObject to be called in these cases|\n|0.5.1|Unique names for unmocked-android.jar to workaround an Android Studio problem|\n|0.6.0|Use Gradle's dependency management to get the android-all.jar, more magic to workaround issues using unmocked Android-6.0+ classes|\n|0.6.1|Make it work with Gradle 4.0-milestone and Android Gradle plugin to 3.0.0.-alpha1 while keep it working on previous versions|\n|0.6.2|Make it work with activated Kotlin plugin|\n|0.6.3|Make it possible to use Gradle 4 with Android Gradle plugin \u003c 3.0|\n|0.6.4|Works with kapt3|\n|0.6.5|Also copy non-class files when they are matched by keepStartingWith|\n|0.7.0|Using downloadFrom will make your build fail - use unmock scoped dependency now|\n|0.7.1|Add support for proper Gradle up-to-date checks (thanks to @drewhannay)|\n|0.7.2|Enable relocatable Gradle build cache support (thanks to @drewhannay)|\n|0.7.3|Several internal improvements (PR 52, 53) contributed by  @drewhannay and @stephanenicolas|\n|0.7.4|Bump Javassist version\n|0.7.5|Allow unmocked classes in any variant (PR 62)\n|0.7.6|Bump Javassist version to 3.27.0-GA\n|0.7.7| ---\n|0.7.8|Gradle 7.0 compatability, contributed by @calvarez-ov\n|0.7.9|Fix #77, contributed by @matejdro\n|0.8.0|#83, contributed by @matejdro\n|0.9.0|#69\n\n## License\n\n```\nCopyright 2015-2024 Björn Quentin\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjoernq%2Funmock-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjoernq%2Funmock-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjoernq%2Funmock-plugin/lists"}