How to run Android / Robotium Instrumentation test applications against the APK version?

I have setup an Android project with its pure Java unit test project running on a PC and its functional / integration test projects running on the emulator. These two use test cases of InstrumentationTestCase2 , as well as the Robotium structure. I can run these two from Eclipse, against debugging the version of my application and collect the results, etc.

I can create release APKs through both Eclipse export and Ant build. APK is signed, zipaligned and obfuscated.

I would like to know how to run those functional / integration tests with the version version of my application, and not the debugging one. I know that I could lure some errors because the application project contains several tests that probably were removed by Proguard, but I can handle it.

I searched on Google and here on SO, but no luck. There is only a page related to testing with Robotium, when you have only the APK application, there is no source. I am not sure if that would really help me. How can I run a test project on a device against releasing an APK?

+7
source share
3 answers
  • Sign both the test release application and the Robotium test application with your release key
  • Install both applications on your device
  • Run the tests using the following command:

adb shell am instrument -w com.your.package / android.test.InstrumentationTestRunner

Where com.your.package is your package name.

See Robotium Q & A for more information: http://code.google.com/p/robotium/wiki/QuestionsAndAnswers

As you already mentioned, you may also have problems with Proguard depending on how you wrote your test cases.

+2
source

I would like to know how to run those functional / integration tests against the release version of my application, and not debugging.

I came across this question looking for a solution.

Since this is an old question with old answers, I will give an updated answer for the Android Gradle project.

What I've done:

  • Let test apk work with the release build type by adding the following:
 android { testBuildType "release" } 
  1. add proguard rules for your apk test as well
 buildTypes { release { minifyEnabled true proguardFiles 'proguard-rules.txt' testProguardFile('proguard-rules.txt') } } 

Now try to run the test against release build. you may still encounter an error due to the proger. if you use Robotium, like me, you can add the following line to your proguard-rules.txt file:

 ##--------------- Begin: proguard configuration for Robotium ---------- -keep class com.robotium.** { *;} ##--------------- End: proguard configuration for Robotium ---------- 

Hope this helps.

+2
source

you need to put ant.properties in the project root of your target application and test application. The contents of ant.properties should look like this: key.alias= key.store.password= key.store= key.alias.password=

+1
source

All Articles