2

I'm able to get a coverage report of my tests using jacoco in my Android application because it is as simple as to execute "createDebugCoverageReport" task. But what I need to do is to exclude some classes from jacoco analysis in order to improve my coverage. I've found some answers googling a lot but they all concerns unit testing. Someone can help me?

Lorenzo Camaione
  • 505
  • 3
  • 15

1 Answers1

0

You did not include many insights in your question. Based on what you wrote I can elaborate that:

You found a lot of answers concerning unit tests because jacoco works with all the tests in a similar fashion. What you need to do, is to follow the same lines:
Jacoco takes care of looking at your tests. Normally you would annotate test with the @Test annotation. Make sure you do that for yours and those you need to exclude insert them in such tag (if you are using maven):

<configuration>
    <excludes>
        <exclude>**/*Config.*</exclude>
        <exclude>**/*Dev.*</exclude>
    </excludes>
</configuration>

If you are using gradle, look at this article instead.

Community
  • 1
  • 1
LoreV
  • 575
  • 5
  • 25
  • I'm using Gradle. I don't need to exclude tests but code that is analyzed to print out a report. I didn't post any code because there isn't any relevant code to show. My goal is to improve code coverage percentage. What I have now comes out from a bad analysis: jacoco is analyzing classes that are not important to tests coverage purposes. I also looked at that answer but I cannot fix in that way beacuse I didn't create any task to create report. I use "createDebugCoverageReport" task and I'm not able to adjust it as suggested in that answer – Lorenzo Camaione Apr 04 '16 at 11:45
  • The analyzed code is based on your tests. In order to improve code coverage you need to create extra test that can reach all the code you wrote for production. If you are not interested in some checks, make sure you exclude them in your gradle config file. – LoreV Apr 04 '16 at 11:51
  • No. It is considering also classes created by other services (e.g. Messages.java class created by Protocol Buffers). I need to exclude this and perhaps other classes from jacoco analysis. – Lorenzo Camaione Apr 04 '16 at 11:55
  • Please check: http://stackoverflow.com/questions/29887805/filter-jacoco-coverage-reports-with-gradle . – LoreV Apr 04 '16 at 12:00