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:
- Then change directory to cd ..\MyProjectTest
- Rename the existing build.xml to build_orig.xml
- Run this command:
- Then, run the command -
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
- Then you should be able to generate the report.