简体   繁体   中英

Code coverage with jacoco for a Android library

I have an Android library (jar file) containing some APIs and I want to do code coverage test for these APIs using Jacoco.

For example, I have a calculator library (may name it calc.jar), having some APIs to do add, subtract, multiple and divide (via some static method such as Calc.doAdd(a,b), Calc.doSubtract(a,b) etc...). Now I have another Android test application (created by Android Studio) using this calculator library. I would like to do code coverage for this calculator library (surely I have calculator library source code).

I am also successfully do code coverage test with EMMA and ant. As Android Studio now uses Gradle for building, so I would like to know if we can do code coverage (I searched and see that Gradle can work with Jacoco).

I do searched and see that there are some topic relating to Jacoco code coverage for Android Application. But I am looking a way for doing code coverage for JAR library using Jacoco and Gradle. Please give me a help. If there are topics relating to this, please help to show me.

Many thanks in advance,

According to Issue 76373 you can't get code coverage for libraries. Some people seems to have been successful with some hacks but I've not found anything that works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM