Get JUnit code coverage on Android.

Setting

For coverage acquisition in Android Studio, Jacoco is supported, so use it.

All you have to do is add one setting to gradle

buildTypes {
    debug {
        testCoverageEnabled true
    }
}

Now you are ready!

Get code coverage

It seems that the git command is used to get it after trying various things, it is troublesome, so I get it by another method.

Click "Gradle" in the upper right corner of Android Studio and it will be displayed like this. With the above settings, "createDebugCoverageReport" should be added, You can get coverage by double-clicking on it. (* Results of instrumented test) At this time, let's start the emulator. image.png

Then you should have coverage in "/ app / build / outputs / reports /"! I will omit the view of coverage because it is annoying.

end

Recommended Posts

Get JUnit code coverage on Android.
Use native code on Android
[Android] Get the date on Monday
[Android] Get the tapped position (coordinates) on the screen
[Android] Notes on xml
Get Android location information
I found no way to get the error code when I received an exception on Android
Sample to get WiFi, Bluetooth beacon, sensor information on Android
How to batch run JUnit and get coverage as well
Customize list view on Android
Multipart transmission library on Android
Run VS Code on Docker
Use serial communication on Android
ROS app development on Android
About types of code coverage
Code Climate Code quality, coverage measurement
Understand code coverage with Rspec, the Ruby on Rails test framework
Get the acceleration and bearing of the world coordinate system on Android
How to get coverage of Android Instrumented Tests [Do your best]