NOTE:

NOTE: Of late, I have been getting requests for very trivial problems that many of you are facing in your day-to-day work. This blog is not to solve your "project" problems - surely not a "Support" site.
I just love to share my knowledge in my spare time and would appreciate any questions or feedback on the articles and code I have shared. I also do appreciate thought-provoking questions that would lead me to write more articles and share.
But please do not put your day-to-day trivial problems here. Even if you do, you most probably would not get a response here.
Thanks

Search This Blog

x

Thursday 19 April 2012

Android - Code Coverage - Unit Testing

This is a very small post for all those who have been strugling to generate the Android Test Coverage Using the ant scripts give by android sdk itself.


I am assuming that you have created one project containing the actual source code to be tested - assume it is called "MyProject" and you have created another test project that tests MyProject, that is named MyProjectTest.


Then, you have written jUnit tests using the inherent testing support framework with android. Now, you have run your unit tests and they run successfully in ecplise. You then, what to check on the code coverage of these unit tests. Here are the steps for the same:



  •    At the command prompt, change directory to the MyProject folder
  •    Rename the existing build.xml to build_orig.xml
  •    Run this command:
android update project -p . (including the last dot)
  •    Then change directory to cd ..\MyProjectTest
  •    Rename the existing build.xml to build_orig.xml
  •    Run this command:
android update test-project -m D:/..../source/MyProject -p .  (including the last dot and where you give your complete path to the MyProject folder after -m)
  •    Then, run the  command -
ant emma debug install test
This should generate a html report of the coverage under MyProjectTest/coverage


Troubleshooting:

  •    Incase you get an error "remote object coverage.ec does not exist" then start adb shell in another command prompt - in order to give write permissions to the sdcard for writing the coverage.ec file
  •    Then, run the following command at the shell
mount -o remount rw /sdcard
  •    Then you should be able to generate the report.


26 comments:

  1. Dear Mam
    How do i able to know android is installed in my system or not?
    Any ans : please help me......

    ReplyDelete
  2. Thank you for the information you've share to us.

    ReplyDelete
  3. Hello Mam,

    Hope you are fine.

    I would like to tell you that your blogs are extremely helpful. I would learn more of android programming in the future from your blogs but before that I want to ask you, have you ever worked on getting android app to connect with AWS, Google app engine or any open source remote database in cloud? if so please share the link so that I can learn from it and start the app development with cloud connect.

    Regards,
    Rahul

    ReplyDelete
  4. Thanks for valuable information...

    ReplyDelete
  5. thanks for the information about Android

    ReplyDelete
  6. I was happy to discover your blog today. I was unable to find a contact link. I hope it’s OK that I’m contacting you through a public comment. We’ve developed live wallpaper for Android called “Star Catcher Live Wallpaper” that lets you slide your finder through the stars on the sky!
    I would appreciate your reviewing “Star Catcher Live Wallpaper” in your blog. You can learn more about the application at

    https://play.google.com/store/apps/details?id=com.belonogov.starcatcherlivewallpaper

    Please let me know if you are interested.
    We need it!
    Thank you very much!
    Alexander Belonogov
    From Under The Blanket
    Email: fromundertheblanket@gmail.com

    https://play.google.com/store/apps/details?id=com.belonogov.starcatcherlivewallpaper

    ReplyDelete
  7. Hi Mam,
    This is Kiran,
    I am trying to get a third party API to access PC from android Table,
    I spent much time on google and did't found any suitable API,
    can you please suggest me the right API to access PC in android app

    Thanks in advance

    ReplyDelete
  8. Hi Mam,
    This is Kiran,
    I am trying to get a third party API to access PC from android Table,
    I spent much time on google and did't found any suitable API,
    can you please suggest me the right API to access PC in android app

    Thanks in advance

    ReplyDelete
  9. Hiii Mam,
    Myself Viraj Deshaval want to learn Android and want to make project based on android as my final year project. As, i am persuing B.E. in CSE i am in need of the company who is providing a training.

    Eagerly waiting for your reply.

    ReplyDelete
  10. Hi Geetha,
    Many thanks for sharing your knowledge. it help me a lot to learn android

    ReplyDelete
  11. Very helpful that is. I have been playing and trying to code some android apps and a few simple games.This will help me a lot.

    ReplyDelete
  12. I infer I haven't interpreted specified incomparable physical anywhere added online.

    Root ICS

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. Respected Mam,
    I am Fresher and got a profile of android developer in my company
    As the very first assignment i got the project to develop a voice mail
    The requirement are
    the ringing goes for 10 seconds and then our previously stored message
    "Mr Xyz is currently unavailable leave the message after the beep" starts playing
    and then the message by the caller (whatever he conveys) is to be saved on our device and that left message by the caller can be listened by the person afterwards as a voicemail, how to stop the ringing "tring tring" and start the our previously stored message coz ringing is coming from the n/w provider plz guide me on this

    ReplyDelete
  15. Hi sai,

    I am try to create walkie talkie app using android but i could n't store the recorded file in sdcard and also i want to know the networking details that like how to send and receive the voice message between one mobile to another mobile process.
    Thanks,
    Tamilarasi.

    ReplyDelete
  16. hi sai,

    please reply as soon as possible because this is very urgent
    Thanks,
    Tamilarasi

    ReplyDelete
  17. Mam iwant code to display excelsheet in android can u please provide me as i want to develop an app regarding it.Please reply me as soon as possible
    Thanks,
    Mahalakshmi

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. Great resource. Thank you. This is indeed very helpful.

    ReplyDelete
  20. The themes here are amazing. I would like to see an easier way to search with more relevant results. i.e. when I search autumn, I really don't want to find Assassins Creed or Warrior girl...just a pretty autumn seasonal theme for my background.

    ReplyDelete
  21. This comment has been removed by the author.

    ReplyDelete
  22. Thank you for sharing this valuable informative article. I am sure that it will help me a lot to know a lot. Waiting to know more from you.

    ReplyDelete
  23. Wow, that really distilled the important information in a great way. Saved me a lot of time!

    ReplyDelete
  24. Good post.
    For people starting the 'testing' now, I would also recommend trying out 'TestNG'. It is better than JUnit for Integration/ Module testing.

    ReplyDelete
  25. This comment has been removed by a blog administrator.

    ReplyDelete
  26. nice posting ,,, this site help me so much to create a andriod program so it really great to read this blod thanks for sharing .........

    ReplyDelete