How to generate jacoco reports for specific module in android studio?
Asked Answered
A

0

9

I am very new to this environment. I came from a native iOS background.

By using this https://blog.gouline.net/code-coverage-on-android-with-jacoco-92ec90c9355e, I am successfully generating the JACOCO test reports for my unit test class in my android project (app module only).

What I am doing is:

  1. I simply create jacoco.gradle file in the main project.
  2. Apply from: '../jacoco.gradle' in app/build.gradle file
  3. Added below code in the app/build.gradle file

    android { 
    ... 
        buildTypes { 
            debug { 
                testCoverageEnabled = true 
             } 
            ... 
        } 
    ... 
    }
    
  4. Open a terminal inside the Android Studio and run the command like

      **gradlew tasks** 
    
  5. To generate a report, run the command

    **gradlew testBlueDebugUnitTestCoverage**
    
  6. Finally I found my reports at this path: \app\build\reports\tests\testTabletDebugUnitTest

By using this http://vgaidarji.me/blog/2017/12/20/how-to-configure-jacoco-for-kotlin-and-java-project/ I have successfully generated the jacoco report for the both Espresso and Coverage test classes (UI and Unit Testing), and also this project includes both java & kotlin classes.

Now my question is: I want to generate the jacoco test reports for specific module out of all other modules in my app.

System Info:

Windows 10, 
Android Studio 3.3.1, 
Kotlin: ext.kotlin_version = '1.3.21'
Gradle:gradle:3.4.0-alpha01. 
Abraxas answered 15/3, 2019 at 15:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.