Search code examples
androidandroid-espressoandroid-testingcircleci

How to run only a test suite with the connectedAndroidTest command


I am having problems with timeouts running my UI tests in circle ci since the command connectedAndroidTest is taking more than 10 minutes to run.

So I am trying to split them into test suits and run each suite at a time.

I found how to create suites for my android tests here: https://developer.android.com/reference/junit/framework/TestSuite.html

But I can't find how to run them with the connectedAndroidTest command.


Solution

  • I have not found any way to execute the TestSuite, but I found two other options to solve my timeout problems with the circle ci tests:

    • Run tests by package:

    ./gradlew app:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.package=<package>

    • Run tests by type:

    ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.size=<small|medium|large>

    You need to add @SmallTest, @MediumTest, @LargeTest to your test classes or methods to split them into the groups and avoid hitting a timeout.

    Another option that I found was to change the timeout of the command:

    - ./gradlew app:connectedCheck -PdisablePreDex:
        timeout: 1800