Brett
first of all thanks for all the information on Emma coverage.
I have written my own instrument testcase for Setting  app and added
these to /packages/apps/Settings/tests/
with export EMMA_INSTRUEMNT=true;and mmm packages/apps/Setting
coverage.em,Settings.apk,SettingsTests.apk are generated.
But when i do adb shell am instrument -w -e coverage true
com.android.settings.tests/android.test.InstruementationTestRunner
 all the tests are performed on emulator but its giving error Error:
Failed to generate emma coverage.

i was able to generate reports for all apps that come with build
(apidemos,Calculator etc).
Is it possible to generate coverage through the tests that wont come
with android.If so what am i missing?
Are there any suggested solutions?
Any help is really appreciated.
thanks and regards
haritha



On May 28, 1:09 pm, Brett Chabot <brettcha...@android.com> wrote:
> + android-platform
>
> Its great to see people interested in EMMA code coverage on Android.
> However, note that EMMA code coverage support on Android is currently quite
> preliminary. Its not supported from within the SDK yet. The support that is
> in place is for apps and tests that are part of the android source tree.
>
> That being said, if you still want to give it a try, download the android
> source for cupcake, do a full build, and give the instructions below a try.
> There are a couple helper scripts that have been created which will
> hopefully make this a bit easier.
> 1. Generating code coverage for your own tests using runtest script
>
> First, you need to add the target system/framework/emma.jar to the device's
> boot classpath. Modify the BOOTCLASSPATH variable in
> /system/core/rootdir/init.rc. The system/framework/emma.jar entry needs to
> be added in the exact position shown below:
>
>  export BOOTCLASSPATH=/system/framework/core.jar:/system/framework/ext.jar:
> */system/framework/emma.jar:*
> /system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar
>
>  Rebuild the bootimage to pick up the init.rc changes:
>
> make bootimage
>
>   Start an emulator with a simulated sdcard:
>
> emulator -sdcard <path to sdcard.img>&
>
>   Note that the emulator will not fully boot up at this point since the
> emma.jar file is not present yet.
>
> Next, use the runtest.py script. Runtest will do all the necessary steps to
> instrument your test and target package, run the test, and generate the code
> coverage report.
>
> % runtest_py --coverage apidemos
> ...
> Coverage report generated at <android build
> root>/out/emma/ApiDemos/apidemos/apidemos.html
>
>  When testing on the emulator, you must launch the emulator with a simulated
> sdcard (-sdcard option), as code coverage results are stored to the sdcard.
> To use runtest_py, the test must be defined in
> development/testrunner/test_defs.xml.
> To generate code coverage results, the test must have a "coverage_target"
> attribute, which must refer to a target defined in
> development/testrunner/coverage_targets.xml
>
> 2. Generating code coverage for your own tests - The Hard Way
>
> The following steps will use apidemos tests as an example, and will assume
> the current working path is the android build root.
>
> Modify the targets BOOTCLASSPATH as described in the preceding section.
>
> Before doing a build, set
>
> export EMMA_INSTRUMENT=true
>
>  This instructs the build system to add the necessary emma instrumentation
> to the generated bytecode.
>
> mmm development/samples/ApiDemos
>
>  Pass in a '-e coverage true' argument to adb shell am instrument when
> executing tests.
>
> adb shell am instrument -w -e coverage true
> com.example.android.apis.tests/android.test.InstrumentationTestRunner
>
>  This command will dump a runtime coverage data file at
> /sdcard/coverage.econ the device. Extract it to local host
>
> adb pull /sdcard/coverage.ec coverage.ec
>
>  Now generate a coverage report. You'll need to pass in the path to the
> coverage metadata generated at build time.
>
> java -cp external/emma/lib/emma.jar emma report -r html -in
> coverage.ec -sp development/samples/ApiDemos/src -in
> out/target/common/obj/APPS/ApiDemos_intermediates/coverage.em
>
> I hope this helps.
>
> Regards,
> Brett.
>
> On Wed, May 27, 2009 at 9:25 PM, Deeps <l.prade...@gmail.com> wrote:
>
> > Thanks a lot Felipe.
>
> > Yeah..I have included emma.jar in the build path of my application.
> > I have the android latest release 1.5 sdk.. However, my application
> > has 1.1 target. I tried using Android JUnit and found all my test
> > cases are executed.
> > And also throu command prompt i followed the syntax mentioned in the
> > earlier post..
>
> > Still coverage is 0.0% but i could see the no of instructions. Will
> > there be a solution?
>
> > Thanks
> > Deeps
>
> > On May 27, 5:33 pm, Felipe Ramos <felipe.wo...@gmail.com> wrote:
> > > Hi Deeps,
> > > Nice to hear that you are making progress. Are you using only the SDK, or
> > > are you building the entire android source code? Maybe your code is not
> > > instrumented to generate the coverage statistics and this would be why
> > you
> > > are getting 0% of code coverage. Are you using the emma.jar provided on
> > the
> > > Emma site, or the one built in Android source code??
> > > I'll try to reproduce what you have done up to now here. I hope we can
> > > manage to get a final solution for this matter.
> > > BR
> > > Felipe
>
> > > On Tue, May 26, 2009 at 3:26 AM, Deeps <l.prade...@gmail.com> wrote:
>
> > > > Felipe,
>
> > > > Atlast i am half way through in getting the coverage file. But..I dont
> > > > see any required output in that file.
>
> > > > I created a sdcard. Then i run my Instrumentation with the following
> > > > command,
> > > > # am instrument -e coverage true -w com.app.exam.tests/
> > > > android.test.InstrumentationTestRunner
>
> > > > First I got error, Is EMMA jar included.
>
> > > > So, i added the amma.jar in the build path. Again I ran the same
> > > > command. Then, I found a coverage file , "coverage.ec" while
> > > > navigating thro file explorer of ddms. I pulled it to the desktop and
> > > > imported the session to Coverage field in eclipse.
>
> > > > Its unfortunate that I dont see any code coverage but i could see only
> > > > the number of instructions.Even though my test cases has run and the
> > > > results has displayed, I am getting 0.0% code coverage..
>
> > > > Can u please try this and share ur experience..
>
> > > > Deeps
>
> > > > On May 21, 9:25 pm, Felipe Ramos <felipe.wo...@gmail.com> wrote:
> > > > > Hi deeps,
>
> > > > > I'm stuck on the point where I need to run the instrumented tests on
> > > > > the emulator. I could not find a way yet to make the emulator believe
> > > > > that theemma.jar is already installed on it.
>
> > > > > Also, I don't know if there is a way of enablingEMMAinstrumentation
> > > > > using the SDK. I have not tried that yet. I'm using theandroidfull
> > > > > source, compiling it from scratch. I think I'm close, at least to run
> > > > > it on the emulator, but on this past week I was too busy and could
> > not
> > > > > investigate more about this issue. I'm planning to put everything I
> > > > > know on a blog or something like that, at least to help the other
> > > > > developers that are trying to makeEMMAwork onAndroid, since I could
> > > > > not find relevant references on this matter from the Google guys.
>
> > > > > I'll send later a step by step of what I made up to now... I'm
> > > > > currently at my job, so I don't have much time to write right now.
>
> > > > > BR
>
> > > > > Felipe
>
> > > > > On May 21, 10:00 am, Deeps <l.prade...@gmail.com> wrote:
>
> > > > > > Felipe Ramos,
>
> > > > > > Did u end up somewhere..? I am not able to go ahead with this......
>
> > > > > > deeps- Hide quoted text -
>
> > > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to