gojuno / composer

Reactive Android Instrumentation Test Runner. Archived. Marathon is recommended as an alternative (https://github.com/Malinskiy/marathon).
Apache License 2.0
546 stars 45 forks source link

Adding support for Android Test Orchestrator #157

Closed jonas-m- closed 5 years ago

jonas-m- commented 5 years ago

This fixes #90, closes #131 and closes #135

Tested in production - works perfectly, also the report generation

One point of uncertainty - the requirement to install test orchestrator and test services APKs before running the tests. I'm not convinced that this should be something composer itself should be concerned with, as those APKs just need to be installed, no parsing is done on them otherwise (as opposed to normal app/test APKs)

The installation can either be done manually (as described in the official docs) OR, if used with Gradle - with a custom task, something like this:

android {
    defaultConfig {
        ...

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments clearPackageData: 'true'
    }
    testOptions {
        execution 'ANDROID_TEST_ORCHESTRATOR'
    }
}

dependencies {
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestUtil 'com.android.support.test:orchestrator:1.0.2'
}

task installTestUtils() {
    doFirst {
        // Resolve and install all files associated with androidTestUtil configuration, which will be both - test services and the orchestrator APKs
        configurations.androidTestUtil.resolvedConfiguration.files.forEach { filePath ->
            println "Installing ${filePath} ..."
            exec {
                workingDir projectDir
                commandLine 'adb', 'install', '-r', filePath
            }
        }
    }
}
CristianGM commented 5 years ago

@jonas-m- would you add some unit tests?

jonas-m- commented 5 years ago

@jonas-m- would you add some unit tests?

Sure - will do

yunikkk commented 5 years ago

@jonas-m- sorry again for the delays, finally can handle the PR. Regarding your question about orchestrator and test services apks - seems to me that it's enough to point users that they need to setup it correctly. And we can improve that in future, as well.

Weird enough that issue with orchestrator not printing output is resolved but issue https://issuetracker.google.com/issues/64486480 is not closed)

Thanks a lot for contribution!