How to get code coverage using Android Studio?

前端 未结 9 1939
囚心锁ツ
囚心锁ツ 2020-12-02 07:00

I am developing apps using Android Studio.
I was able to run the test code.
But, I do not know how to get code coverage in android studio.

I have a

相关标签:
9条回答
  • 2020-12-02 08:02

    We use maven to build our app and cobertura for code coverage reporting

    both are really easy to integrate

    android maven integration:

    http://www.vogella.com/tutorials/AndroidBuildMaven/article.html

    Maven + Cobertura Code Coverage Example:

    http://www.mkyong.com/qa/maven-cobertura-code-coverage-example/

    0 讨论(0)
  • 2020-12-02 08:02

    You can just right click on the package you are curious about and select Run 'Tests in "package" with coverage'

    0 讨论(0)
  • 2020-12-02 08:05

    Enable testCoverage in your module build.gradle file

    buildTypes {
            debug {
                testCoverageEnabled true
            }
        }
    

    and then

    Right click on the test -> java package and select Run Tests in Java with Coverage to run all tests with code coverage or right click on the particular test class and click Run SampleTest with Coverage

    0 讨论(0)
提交回复
热议问题