问题
Before using gradle, it seems easy to do some black box testing with robotium or other instrumentation based automation framework, just need to indicate the targetPackage in AndroidManifest.xml
<instrumentation
android:name="com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
android:targetPackage="xxxx" />
However gradle expects a project structure like this:
src/main/
src/androidTest/
It simply use the app built from main (source code) as test target.
And according to Gradle Plugin User Guide
The value of the targetPackage attribute of the instrumentation node in the test application manifest is automatically filled with the package name of the tested app, even if it is customized through the defaultConfig and/or the Build Type objects. This is one of the reason this part of the manifest is generated automatically.
Does it means with gradle we're not able to choose the targetPackage and test an app without source code? Or how to make gradle do the trick?
来源:https://stackoverflow.com/questions/28020893/gradle-android-instrumentation-test-without-app-source-code