7

I have an Android project setup with its pure Java unit test project running on PC, and its functional/ integration test projects running on Emulator. Those two make use of InstrumentationTestCase2 test cases and also Robotium framework. I'm able to run those two from Eclipse, against the debug version of my app and collect results and so on.

I'm able to create a release APK both thru Eclipse export and Ant build. APK is signed, zipaligned and obfuscated.

I'd like to know how to run those functional/ integration test against the release version of my app, instead of the debug one. I know I might encur in some errors because app project contains some test-only classes that probably have been stripped out by Proguard, but I can handle that.

I searched on Google and here on SO, but with no luck. There's only a page here related to testing with Robotium when you only have app's APK, no source. I'm not sure this would really help me. How would I get the test project to run on the device against the release APK?

superjos
  • 12,189
  • 6
  • 89
  • 134

3 Answers3

2
  1. Sign both the release app under test and the test Robotium app with your release key
  2. Install both apps on your device
  3. Run 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 the Robotium Q&A for more info: http://code.google.com/p/robotium/wiki/QuestionsAndAnswers

As you mentioned, you might also have some Proguard issues depending on how you've written your test cases.

theelfismike
  • 1,621
  • 12
  • 18
  • At the moment I'm not working at that project, but the answer is still useful to know. Plus, @Frank has put a bounty on this. Could you please elaborate more on how to proceed? I mean: ok, say you sign the Debug APK and the Release APK with the same (release) key. Then how do you go further? Thanks! – superjos Feb 12 '13 at 09:16
  • 1
    After signing, you'd have to install both the release app under test and the test Robotium app, then start the tests from the command line, via the command "adb shell am instrument -w com.android.foo/android.test.InstrumentationTestRunner", where com.android.foo is your package name. See the Robotium Q&A for more info: http://code.google.com/p/robotium/wiki/QuestionsAndAnswers – theelfismike Feb 12 '13 at 17:28
  • Ok. At the moment I'm not able to test if this works. If @Frank can confirm that, I'm more than happy to mark yours as *the* answer (I guess Frank cannot do that). – superjos Feb 12 '13 at 18:26
  • Yes @theelfishmike is correct. I have edited his reply to make it clearer, and also awarded the bounty. – Frank Harper Feb 13 '13 at 08:45
  • Note, that most likely you need to specify `com.your.package.test`, in other words - package of your test-application (not application itself). – Dmitry Zaytsev Apr 26 '13 at 13:32
2

I'd like to know how to run those functional/ integration test against the release version of my app, instead of the debug one.

I came across this question while searching for a solution..

Since this is an old question with old answers, I shall give an updated answer for Gradle-based Android project.

What I did is:

  1. let test apk run against release build type by adding this:
android {
    testBuildType "release"
}
  1. add proguard rules for your test apk as well
buildTypes {
    release {
        minifyEnabled true
        proguardFiles 'proguard-rules.txt'
        testProguardFile('proguard-rules.txt')
    }
}

Now try to run test against a release build. you may still encounter error due to proguard. if you are using Robotium, like I do, you can add the following line in your proguard-rules.txt file:

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

Hope it helps.

xialin
  • 7,686
  • 9
  • 35
  • 66
1

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

butazoo
  • 11
  • 1
  • 1
    Hello. Thanks for answer. I think this is needed in order to create the release APK (sign it, and so on). That operation is already happening. What I was after was to run functional/integration tests against the release version APK. – superjos Jul 17 '12 at 14:34