I know of
ant coverage
However that does a few things, it compiles with emma instrumentation, installs, and runs the test apk. I don't want it to run the test suite through ant with coverage because I need to run it with some extra hooks, and I don't want to run the large test suite twice. So far I have tried this
Target_Project/build.properties
emma.enabled=true
Test_Project/build.properties
emma.enabled=true
Then in in a shell I execute this.
Target_Project$ ant debug
Target_Project$ adb install bin/Target_Project-debug.apk
Target_Project$ cd ../Test_Project/
Test_Project$ ant debug
Test_Project$ adb install bin/Test_Project-debug.apk
Test_Project$ adb shell am instrument -e coverage true -e coverageFile /sdcard/myFile.ec -w com.my_app.testproject/android.test.InstrumentationTestRunner
The response is
Error: Failed to generate emma coverage. Is emma jar on classpath?
So is there a trick to getting the apk to build with the emma libs? I tried invoking the targets created in the sdk xml templates but they are "private." Is there something I am missing?
Well for anyone interested. The SDK documentation is completely busted (surprising I know). Basically you have to do this,
take the base build.xml generated by android create-project and change the tag
<setup/>
and change it to
<setup import="false"/>
Now the documentation will tell you to copy from SDK/platform-/templates/android_rules.xml and place that into your build.xml ...
THIS IS WRONG and horribly unmaintained. This rules file isn't used by anything. What is used are the rules inside of SDK/tools/ant/. Grab the appropriate file for your type of project (library for a library project, test for a test project, or vanilla for a regualr project) with the latest _r and
copy the contents of it's root node into your build.xml. Insert it after the setup tag. If you don't use the files inside the ant directory, you will not be able to compile project libraries through the ant script. I was so glad they maintained documentation on how to do this.
Now you can change whatever you like in the build file to match your build needs. In which case I just made install-helper call my wrapper around adb which returns interpreted resultcodes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With