From a1ba9c2936f73415bf88b97df5fe41157e39112b Mon Sep 17 00:00:00 2001 From: hzl Date: Thu, 2 Jun 2016 11:22:12 -0700 Subject: [PATCH] Added instructions on how to use code coverage. Added coverage.md file for emma code coverage instructions for both instrumentation and junit tests. BUG=608085 Review-Url: https://codereview.chromium.org/2031743002 Cr-Original-Commit-Position: refs/heads/master@{#397474} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 1ccac19f89c5bcc7bdd978384520b9cfd218f14f --- android/docs/coverage.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 android/docs/coverage.md diff --git a/android/docs/coverage.md b/android/docs/coverage.md new file mode 100644 index 000000000..0a179876c --- /dev/null +++ b/android/docs/coverage.md @@ -0,0 +1,32 @@ +# Android code coverage instructions + +This is instruction for code coverage 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 +build/android/generate_emma_html.py script. + +## How to collect EMMA coverage data + +1. Build your APK with the GN arg emma_coverage=true. + ``` + gn args out-gn/Debug + > target_os = "android" + > emma_coverage = true + ``` + By doing so, **.em** files will be created in out-gn/Debug. +2. Run tests, with option `--coverage-dir `, 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: + `build/android/generate_emma_html.py --coverage-dir /tmp/coverage/ + --metadata-dir out-gn/Debug/ --output example.html`. + Then an example.html containing coverage info will be created: + `EMMA: writing [html] report to + [/example.html] …`