forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update EMMA code coverage documentation.
Review-Url: https://codereview.chromium.org/2426583004 Cr-Commit-Position: refs/heads/master@{#425925}
- Loading branch information
Showing
1 changed file
with
23 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,42 @@ | ||
# Android code coverage instructions | ||
|
||
This is instruction for code coverage for android instrumentation and junit tests. | ||
These are instructions for collecting code coverage data for android | ||
instrumentation and junit tests. | ||
|
||
[TOC] | ||
|
||
## How EMMA coverage works | ||
|
||
In order to use EMMA code coverage, we need to create build time **.em** file and runtime | ||
**.ec** file. Then we need to process them using the | ||
In order to use EMMA code coverage, we need to create build time **.em** files | ||
and runtime **.ec** files. Then we need to process them using the | ||
build/android/generate_emma_html.py script. | ||
|
||
## How to collect EMMA coverage data | ||
|
||
1. Build your APK with the GN arg emma_coverage=true. | ||
1. Use the following GN build arguments: | ||
``` | ||
gn args out-gn/Debug | ||
> target_os = "android" | ||
> emma_coverage = true | ||
target_os = "android" | ||
emma_coverage = true | ||
emma_filter = "org.chromium.chrome.browser.ntp.*,-*Test*,-*Fake*,-*Mock*" | ||
``` | ||
By doing so, **.em** files will be created in out-gn/Debug. | ||
The filter syntax is as documented for the [EMMA coverage | ||
filters](http://emma.sourceforge.net/reference/ch02s06s02.html). | ||
|
||
Now when building, **.em** files will be created in the build directory. | ||
2. Run tests, with option `--coverage-dir <directory>`, to specify where to save | ||
the .ec file. For example, you can run chrome junit tests: | ||
`out-gn/Debug/bin/run_chrome_junit_tests --coverage-dir /tmp/coverage`. | ||
3. Now we have both .em and .ec files. We can merge them and create a html file, | ||
using generate_emma_html.py. For example, generate_emma_html.py can be called | ||
this way: | ||
`out/Debug/bin/run_chrome_junit_tests --coverage-dir /tmp/coverage`. | ||
3. Turn off strict mode when running instrumentation tests by adding | ||
`--strict-mode=off` because the EMMA code causes strict mode violations by | ||
accessing disk. | ||
4. Use a pre-L Android OS (running Dalvik) because code coverage is not | ||
supported in ART. | ||
5. The coverage results of junit and instrumentation tests will be merged | ||
automatically if they are in the same directory. | ||
6. Now we have both .em and .ec files. We can create a html report using | ||
`generate_emma_html.py`, for example: | ||
`build/android/generate_emma_html.py --coverage-dir /tmp/coverage/ | ||
--metadata-dir out-gn/Debug/ --output example.html`. | ||
--metadata-dir out/Debug/ --output example.html`. | ||
Then an example.html containing coverage info will be created: | ||
`EMMA: writing [html] report to | ||
[<your_current_directory>/example.html] …` |