Running Android UI Tests - Collect logs, record a video, dump db, preferences and more. Clear data, run by tags and with params. Run in parallel. Easy extendable.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Running Android UI Tests

Blog posts

📗 Part 1 -

  1. Building Execution Plan.
  2. Collect Logs, Record Video, Dump DB, Shared Preferences.
  3. Add ‘Clear data’ support.
  4. Add ‘Clear notifications’ support.
  5. Add parameterized support.
  6. Run tests by #tags.
  7. Dump network stats, battery, alarms and more.
  8. All together.

📗 Part 2 -

  1. Parallel tests execution.
  2. Grouping following tests.

Test Options

We write UI tests same as before. But now, we can add more annotations that will give us more options. 

  • @ClearData - Clear data via ADB before test execution.
  • @ClearNotifications - Clear notification bar via ADB before running the test.
  • @Repeat - Repeat the same test X number of times, when current iteration is passed to the test.
  • @Tags - You can tag your tests. Later, you can run tests by selected tags only.
  • @Following - Will enforce grouping following tests on the same device when running in parallel.

Test example

public class ExampleInstrumentedTest {

    public IntentsTestRule<MainActivity> mActivity = new IntentsTestRule<>(MainActivity.class);
    private final String[] params = new String[]{
            "a", "A", "Aa"

    @Parameterized.Repeat(count = 3)
    @Tags(tags = {"sanity", "small", "sample"})
    public void someTest() throws Exception {
        String param = params[Parameterized.getIndex()];
        assertEquals("a", param.toLowerCase());

    public void someTestFollowing() throws Exception {
        assertEquals("a", "A".toLowerCase());


In addition to new added options, after each failed test, we fetching and building useful files that will help us investigate failed issues better.

  • Recording (mp4)
  • Logs
  • DB (sqlite)
  • Shared preferences
  • Dumpsys - Netstats, battery, other.

Run this sample


  1. Clone the repo.
  2. Connect one or more real devices / emulators.
  3. Run on Mac / Ubuntu / Anything that has bash 3.2 (and above)


# ---- assemble and install the app + test apks ----
# build app APK
./gradlew assembleDebug --stacktrace
# build test APK
./gradlew assembleAndroidTest --stacktrace
# install app APK
adb install -r app/build/outputs/apk/app-debug.apk
# install test APK
adb install -r app/build/outputs/apk/app-debug-androidTest.apk

# ---- prepare and run the tests ----
# create tests raw file
./scripts/ artifacts/raw-tests.txt
# build execution plan and filter by tags
./scripts/ artifacts/raw-tests.txt artifacts/execution-plan.txt
# run the tests
./scripts/ artifacts/execution-plan.txt artifacts

Detailed docs


Roman Kushnarenko - sromku


Apache 2.0