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:
This should generate a html report of the coverage under MyProjectTest/coverage
Troubleshooting:
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.
No comments:
Post a Comment