Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5998509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:24:59+00:00 2026-05-23T00:24:59+00:00

I want to get code coverage when running unit tests. I run ant coverage

  • 0

I want to get code coverage when running unit tests.
I run ant coverage using standard android build.xml for tests.

Tests run well. The last strings from ant coverage are

Tests run: 59,  Failures: 1,  Errors: 4

Generated code coverage data to /data/data/my.package/files/coverage.ec

But the coverage.ec file is only 37 bytes long and is almost empty.

Running emma report on it tells

no collected coverage data found in any of the data files [all reports will be empty]

and generates beautiful report with ZEROES in every field of it.

I suppose that emma should generate a bigger coverage.ec.

What am I doing wrong?

— update —

Did some deep digging. It seems that most of things are well except coverage result generation.

1) It compiles everything saying

[javac] /blabla/android-sdk-linux_x86/tools/ant/main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 88 source files to /blabla/project/tests/instrumented/classes
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.

2) It is doing <instr> with mode="overwrite" for the project that is under test. The path is ok.

-emma-instrument:
[echo] Instrumenting classes from /blabla/project/tests/instrumented/classes…

As a result, there is a *.em file with metadata for 98 classes.

3) Some standard android conversion to dex, package to unaligned, zip align. Result is /blabla/project/tests/instrumented/project-debug.apk.

4) Installing this project-debug.apk onto emulator.

5) Compiling the tests project.
compile:
[javac] /blabla/android-sdk/android-sdk-linux_x86/tools/ant/main_rules.xml:384: warning: ‘includeantruntime’ was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 110 source files to /blabla/project/tests/bin/classes

Source files include all the previous files plus tests (110 = 88 + tests), as stated in build.properties (multiple source.dir separated by “;”).

6) Resources, Dex, signing, zip align… Result is projectTest-debug.apk

7) Installing projectTest-debug.apk onto emulator.

8) Running tests through am where “coverage on” specified. It tells that

[exec] Generated code coverage data to /data/data/blabla.project/files/coverage.ec

9) This coverage.ec contains no relevant data. It is 37 bytes long. Report on it tells that

processing input file [/home/ubuntu/projects/ppf2/workspace/PPF2/tests/coverage.ec] ...
loaded 0 coverage data entries
...
no collected coverage data found in any of the data files [all reports will be empty]

Everything seems good for me except the last step.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:25:00+00:00Added an answer on May 23, 2026 at 12:25 am

    Finally, after many hours of fighting, question resolved.
    Resolution is very simple and unexpectable.

    In build.properties of the TEST project I had something like:

    tested.project.dir=..
    env.WORKSPACE= /bla/bla
    source.dir=${env.WORKSPACE}/first/src;${env.WORKSPACE}/second/src;${env.WORKSPACE}/andsoon/src;
    

    But! I should NOT specify source.dir here! Specifying tested.project.dir is enough to compile test project successfully.

    Moreover, if I specify source.dir in TEST project like this – tests run well but emma reports zero coverage, just as stated in question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get the UCS-2 code points for a given UTF-8 string. For
The following code will generate a link to the page I want to get
I've decided I want to get more into native code development with C++. I'm
I want to capture the screen in my code to get an image -
I want to be able to get an estimate of how much code &
I want to be able to get an estimate of how much code &
I want to get started doing some game development using Microsoft's XNA. Part of
I am trying to get a better code coverage with my unittests, and recently
I use EF code-first 4.1. in my application. Now I want to get entities
i want to get the 10 google search results links (href) using mechanize so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.