{"id":19600618,"url":"https://github.com/stanwood/ui_testing_android","last_synced_at":"2026-04-18T12:02:22.016Z","repository":{"id":92390553,"uuid":"137212168","full_name":"stanwood/ui_testing_android","owner":"stanwood","description":"Define Android UI tests with JSON 🤓","archived":false,"fork":false,"pushed_at":"2018-10-29T14:22:06.000Z","size":1355,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2025-02-26T15:34:22.635Z","etag":null,"topics":["android","json","ui-testing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stanwood.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":"2018-06-13T12:25:17.000Z","updated_at":"2018-10-29T14:22:04.000Z","dependencies_parsed_at":"2023-05-17T02:30:20.518Z","dependency_job_id":null,"html_url":"https://github.com/stanwood/ui_testing_android","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/stanwood/ui_testing_android","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanwood%2Fui_testing_android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanwood%2Fui_testing_android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanwood%2Fui_testing_android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanwood%2Fui_testing_android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stanwood","download_url":"https://codeload.github.com/stanwood/ui_testing_android/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanwood%2Fui_testing_android/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31967993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","json","ui-testing"],"created_at":"2024-11-11T09:15:37.369Z","updated_at":"2026-04-18T12:02:22.001Z","avatar_url":"https://github.com/stanwood.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Release](https://jitpack.io/v/stanwood/ui_testing_android.svg?style=flat-square)](https://jitpack.io/#stanwood/ui_testing_android)\n\n# Stanwood UI testing framework\n\nThis library contains helper classes for UI testing, making screenshots etc.\n\n# Table of contents\n\n- [Import](#import)\n- [Add test class](#add-test-class)\n- [Resource ids](#resource-ids)\n- [Supported actions](#supported-actions)\n- [Run tests](#run-tests)\n- [Roadmap](#roadmap)\n\n\n## Import\n\nThe Stanwood UI testing framework is hosted on JitPack. Therefore you can simply import it by adding the following text to your apps's `build.gradle`.\n\n```groovy\nallprojects {\n    repositories {\n        ...\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\n\nThen add this to you app's `build.gradle`:\n\n```groovy\ndependencies {\n    androidTestImplementation \"com.github.stanwood:ui_testing_android:\u003cadd latest version here\u003e\"\n    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'\n    androidTestImplementation 'com.android.support.test:runner:1.0.2'\n    androidTestImplementation 'com.android.support.test:rules:1.0.2'\n    androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'\n    androidTestUtil 'com.android.support.test:orchestrator:1.0.2'\n}\n```\n\nMake sure to always clean the project after updating any of these test dependencies, the Android Gradle Plugin doesn't always seem to automatically pick up these changes when building the test artifacts.\n\nAlso in `build.gradle` setup the orchestrator as described in the [documentation](https://developer.android.com/training/testing/junit-runner#ato-gradle).\n\n## Add test class\n\nA simple test class SUITest needs to be added to the following folder\n![TestClassFolder](/images/img_test_path.png)\n\n```java\n@RunWith(AndroidJUnit4.class)\n@SdkSuppress(minSdkVersion = 18)\npublic class SUITest extends BaseTest {\n\n    private static final String JSON_SCHEMA_FILE = \"res/raw/test_schema.json\";\n\n    @Before\n    public void start() {\n        SlackTracker slackTracker = new SlackTracker(\n                \"\u003cadd slack channel name here\u003e\",\n                \"\u003cadd slack team id here\u003e\",\n                \"\u003cadd slack token here\u003e\");\n        //FirebaseSchemaProvider schemaProvider = new FirebaseSchemaProvider(\"io.stanwood.uitesting.demo\", \"1.0.0\");\n        ResourceSchemaProvider schemaProvider = new ResourceSchemaProvider(this, JSON_SCHEMA_FILE, BuildConfig.APPLICATION_ID);\n        super.initTests(schemaProvider, slackTracker);\n    }\n\n    // DO NOT leave this method out: it just does the super call, but adds the @Test annotation!\n    @Test\n    public void runTests() {\n        super.runTests();\n    }\n\n}\n```\n\nSame class in Kotlin:\n\n```kotlin\nconst val JSON_SCHEMA_FILE = \"res/raw/test_schema.json\"\n\n@RunWith(AndroidJUnit4::class)\n@SdkSuppress(minSdkVersion = 18)\nclass SUITest : BaseTest() {\n\n    @Before\n    fun start() {\n        ResourceSchemaProvider(this, JSON_SCHEMA_FILE, BuildConfig.APPLICATION_ID).let {\n            super.initTests(it)\n        }\n    }\n\n    @Test\n    public override fun runTests() {\n        super.runTests()\n    }\n}\n```\n\n## Resource ids\n\n1. Start the app within emulator or on a device(needs to be connected to the computer)\n2. Start uiautomatorviewer (usually at /Users/username/Library/Android/sdk/tools/bin)\n./uiautomatorviewer\n3. Pick the desired device (click at an upper 'phone' icon)\n![UiAutomatorViewer](/images/img_uiautomatorviewer_1.png)\n4. UIAutomatorViewer has made a screenshot of current screen. Now you can explore all the visible views and get their resource ids, which are needed in order to be able to look for them within tests\n![UiAutomatorViewer](/images/img_uiautomatorviewer_2.png)\nOn the left side you can see a screenshot of the current view.\nOn the right side you see all the views used within current activity.\nIn this particular case the resource id of the selected view is: countryTitle\nThis id is being used within test if we want to do some action on that view, or maybe just test if the view is being displayed\nThere might be the case that a view does not have resource id defined yet, especially when/if databinding is being used. In that case the developer either needs to define a resource id for that view in the XML layout or you search for the View by the text on it.\n\n## Supported actions\n\n[Actions](/library/src/main/java/io/stanwood/uitesting/model/Action.java)\n\nDots (`.`) in texts need to be escaped with two backslashes like so: `\\\\.`.\n\n#### Json example\n```json\n  {\n    \"initial_sleep_time\": 2000,\n    \"command_sleep_time\": 1000,\n    \"launch_timeout\": 5000,\n    \"view_timeout\": 10000,\n    \"auto_snapshot\": false,\n    \"test_cases\": [\n      {\n        \"id\": \"1\",\n        \"title\": \"Simple button click test\",\n        \"description\": \"Simple button click test\",\n        \"enabled\": true, // optional, true by default, can be used to quickly disable test cases\n        \"navigation\": [\n          \"view['@button'].setText['12345']\", // set text on EditText defined by resource ID\n          \"sleep\",\n          \"snapshot\",\n          \"view['text with a dot\\\\. Do not forget to escape!'].tap\", // tap on View defined by its text\n          \"sleep\",\n          \"snapshot\"\n        ]\n      }\n    ]\n  }\n```\n\nFor quick tests the json file can be stored within an app (under /res/raw/test_schema.json).\nBut in most cases the test schema file should be stored as a resource which can be grabbed via http request (https://console.firebase.google.com/u/0/project/stanwood-ui-testing/database/stanwood-ui-testing/data)\n\n## Run tests\n\nThere are two ways how to run tests\n\n#### Within the Android Studio IDE\n\nSelect SUITest class in the left Navigator view, right click it, and select \"Run/Debug SUITest\"\n#### With a helper script\n[Script](run_ui_tests.sh)\n\n```./run_ui_tests -a app.id.to.test -c full.reference.to.a.test.class -b BuildName [-e avd_name]```\n\n**-a**, **--app-id** - app id\u003cbr/\u003e\n**-c**, **--test-class** - full reference to the class that runs tests\u003cbr/\u003e\n**-b**, **--build** - build/flavour name (Release, Debug, FlavorDebug, Qa, etc.)\u003cbr/\u003e\n**-e**, **--avd-name** - *optional* - avd image name that will be started where test will be executed\u003cbr/\u003e\n\n\nFor more information check out the sample app.\n\n## Roadmap\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanwood%2Fui_testing_android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstanwood%2Fui_testing_android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanwood%2Fui_testing_android/lists"}