How to run UiAutomator 2.0 tests from command line

In your projects base folder execute the following runTests.sh file:
adb install -r app/build/outputs/apk/app-debug.apk
adb install -r app/build/outputs/apk/app-debug-androidTest-unaligned.apk
# Grant permissions requested
adb shell pm grant com.example.test.uiautomatortest android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.example.test.uiautomatortest android.permission.WRITE_EXTERNAL_STORAGE
# Run Ui tests from test class
adb shell am instrument -w -e class com.example.test.uiautomatortest.UiTests com.example.test.uiautomatortest.test/android.support.test.runner.AndroidJUnitRunner
# Pull all screenshots from device
adb pull sdcard/Screenshots/ .
# Restore device
adb uninstall com.example.test.uiautomatortest
adb uninstall com.example.test.uiautomatortest.test

Remember :
chmod +x runTests.sh
./runTests.sh

Dette indlæg blev udgivet i Ikke kategoriseret. Bogmærk permalinket.