I test my Android application using calabash-android , which provides it with its own “test project” with a script that renames its package to reflect the application under test, and then uses the InstrumentationTestRunner subclass:
adb shell am instrument -w -e class sh.calaba.instrumentationbackend.InstrumentationBackend #{ENV['TEST_PACKAGE_NAME']}/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner
I will accept any answer that allows me to generate a code coverage report similar to Emma or Cobertura for an Android application, with data collected during testing in calabash-android.
In an attempt to get Emma's job, I have ...
- Tried to follow these instructions to get Maven to create my project (because it was too long since I used ant). The
coverage.em file is created in target/emma - Calabad android script changed by adding "
-e coverage true " - When I launch calabash-android, I finally see "Generated coverage data in /data/data/my.project/files/coverage.ec"
adb -e pull /data/data/my.project/files/coverage.ec coverage.ec
... so now I should be able to run:
java -cp $ANDROID_HOME/tools/lib/emma.jar emma report -r html -in target/emma/coverage.em,coverage.ec
but I get an error:
EMMA: processing input files... java.io.UTFDataFormatException: malformed input around byte 107
... Therefore, I assume that something is wrong with the android maven plugin , and I'm trying to figure out how to generate coverage.em . I ran " android update project -p . " And " ant emma " and " ant emma debug ", but I can't find the .em coverage area anywhere ...
... The generated build.xml file apparently implies that the coverage.em file is generated only when "ant emma test" is run, but I don’t think this will work because the test application is controlled by the calabad android.
In an attempt to get a Cobertura job, I have ...
- Googled various forms of "cobertura android", but it looks like someone is out of luck.
- Tried to configure cobertura profile in my maven maven file for tool classes, but (in Maven 3) I get
- a whole bunch of warnings about log4j and ant with InnerClasses attributes and that I have to recompile them from the source
- error com.jayway.maven.plugins.android.generation2: android-maven-plugin: 3.3.0: dex "ANDROID-040-001: Failed to execute: Command = / bin / sh -c -cd / path / to / myproject & java -jar $ ANDOID_HOME / platform-tools / lib / dx.jar --dex ... "
EXCEPTION FROM SIMULATION: local variable type mismatch: attempt to set or access a value of type java.lang.Class using a local variable of type java.lang.reflect.Type[]. This is symptomatic of .class transformation tools that ignore local variable information.
... This is probably why no one was able to get cobertura to work on Android?
source share