Re: [java code coverage] Is there any document/blogpost describing the step by step process of JaCoCo offline instrumentation in Android

2020-01-21 Thread Rolf Smit
Jacoco support is build in into the Android tooling (Android Gradle
Plugin). Android supports two different types of tests: instrumented
unit-tests (on device, phone) and non-instrumented unit-tests (on
development machine/build-server etc.).

The documentation on instrumented tests cleary states that you need to use
offline instrumentation, I quote:

*To generate code coverage files (*.ec) that can be used by EMMA or JaCoCo:
-e coverage true Note: For this to work, your classes have to be
instrumented offline (i.e. at build time) by EMMA/JaCoCo. By default, the
code coverage results file will be saved in a /data/data//files/coverage.ec
 file, unless overridden by coverageFile flag (see
below)*

Source:
https://developer.android.com/reference/androidx/test/runner/AndroidJUnitRunner

To enable code coverage (jacoco) in an Android project just enable
`testCoverageEnabled` in the Android module build.gradle file:

android {
buildTypes {
debug {
testCoverageEnabled true
}
}
}

This wil make sure .exec files are generated (for instrumented tests .ec
files). Additional configuration might be required, for example if you use
Robolectric you will very likely need something like this:

tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}

However instead of doing allot of configuration yourself I highly recomend
to use a plugin that takes care of most of the configuration (multi-module
coverage or Kotlin support can be quite a pain to setup). A plugin that
does this can be found here (note: I'm the author of this plugin):
https://github.com/NeoTech-Software/Android-Root-Coverage-Plugin

Regards,

Rolf Smit

On Wed, 22 Jan 2020 at 07:42, Marc Hoffmann 
wrote:

> Hi Sam,
>
> AFAIK apk archive already contain dex files (not class files). JaCoCo only
> works in class files.
>
> I think indeed with offline instrumentation it is possible to instrument
> class files before dex files and the apk are created. As I’m not a Android
> developer I can’t tell you details about the setup. A quick google search
> results in several blogs from people who use JaCoCo for Android.
>
> Regards,
> -marc
>
>
>
> On 14. Jan 2020, at 19:22, testerguy1...@gmail.com wrote:
>
> The testing tool only uses the android apk, not the source code. Can I
> still use the Java agent? If so, how do I instrument the apk using Java
> agent?
> Is there any sample project available that used java agent to instrument
> the apk? I am really sorry if I am asking dumb questions.
>
> Regards,
> Sam
>
> On Monday, January 13, 2020 at 11:20:26 PM UTC-6, Marc R. Hoffmann wrote:
>>
>> Hi,
>>
>> why do you think you need offline instrumentation? Using the JaCoCo Java
>> agent is very convenient and documented here:
>>
>> https://www.jacoco.org/jacoco/trunk/doc/agent.html
>>
>> Regards,
>> -marc
>>
>> On 14. Jan 2020, at 01:05, tester...@gmail.com wrote:
>>
>> Dear All,
>>
>> I am trying to use JaCoCo to measure the coverage achieved by an
>> automated testing tool that uses appium and python.
>> I checked the JaCoCo official webpage for offline instrumentation but
>> didn't understand the process properly. I would be really grateful if
>> someone can give a step by step procedure to do the JaCoCo offline
>> instrumentation in Android.
>> A blog post on this topic would be really helpful to the new users.
>>
>> Thank you!
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "JaCoCo and EclEmma Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to jac...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jacoco/142163e8-fe60-4a0a-8f41-e186ee1c51d8%40googlegroups.com
>> 
>> .
>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jacoco+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jacoco/5113efe9-9b9e-4ef3-b519-6ef6588820cf%40googlegroups.com
> 
> .
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jacoco+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jacoco/49B6654A-9B05-465A-8897-0A101DF33EA8%40mountainminds.com
> 
> .
>

-- 
You received this 

Re: [java code coverage] Is there any document/blogpost describing the step by step process of JaCoCo offline instrumentation in Android

2020-01-21 Thread Marc Hoffmann
Hi Sam,

AFAIK apk archive already contain dex files (not class files). JaCoCo only 
works in class files.

I think indeed with offline instrumentation it is possible to instrument class 
files before dex files and the apk are created. As I’m not a Android developer 
I can’t tell you details about the setup. A quick google search results in 
several blogs from people who use JaCoCo for Android.

Regards,
-marc



> On 14. Jan 2020, at 19:22, testerguy1...@gmail.com wrote:
> 
> The testing tool only uses the android apk, not the source code. Can I still 
> use the Java agent? If so, how do I instrument the apk using Java agent? 
> Is there any sample project available that used java agent to instrument the 
> apk? I am really sorry if I am asking dumb questions.
> 
> Regards,
> Sam  
> 
> On Monday, January 13, 2020 at 11:20:26 PM UTC-6, Marc R. Hoffmann wrote:
> Hi,
> 
> why do you think you need offline instrumentation? Using the JaCoCo Java 
> agent is very convenient and documented here:
> 
> https://www.jacoco.org/jacoco/trunk/doc/agent.html 
> 
> 
> Regards,
> -marc
> 
>> On 14. Jan 2020, at 01:05, tester...@gmail.com  wrote:
>> 
>> Dear All,
>> 
>> I am trying to use JaCoCo to measure the coverage achieved by an automated 
>> testing tool that uses appium and python. 
>> I checked the JaCoCo official webpage for offline instrumentation but didn't 
>> understand the process properly. I would be really grateful if someone can 
>> give a step by step procedure to do the JaCoCo offline instrumentation in 
>> Android. 
>> A blog post on this topic would be really helpful to the new users.
>> 
>> Thank you!
>> 
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "JaCoCo and EclEmma Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jac...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jacoco/142163e8-fe60-4a0a-8f41-e186ee1c51d8%40googlegroups.com
>>  
>> .
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to jacoco+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jacoco/5113efe9-9b9e-4ef3-b519-6ef6588820cf%40googlegroups.com
>  
> .

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jacoco+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/49B6654A-9B05-465A-8897-0A101DF33EA8%40mountainminds.com.


Re: [java code coverage] Is there any document/blogpost describing the step by step process of JaCoCo offline instrumentation in Android

2020-01-14 Thread testerguy1232
The testing tool only uses the android apk, not the source code. Can I 
still use the Java agent? If so, how do I instrument the apk using Java 
agent? 
Is there any sample project available that used java agent to instrument 
the apk? I am really sorry if I am asking dumb questions.

Regards,
Sam  

On Monday, January 13, 2020 at 11:20:26 PM UTC-6, Marc R. Hoffmann wrote:
>
> Hi,
>
> why do you think you need offline instrumentation? Using the JaCoCo Java 
> agent is very convenient and documented here:
>
> https://www.jacoco.org/jacoco/trunk/doc/agent.html
>
> Regards,
> -marc
>
> On 14. Jan 2020, at 01:05, tester...@gmail.com  wrote:
>
> Dear All,
>
> I am trying to use JaCoCo to measure the coverage achieved by an automated 
> testing tool that uses appium and python. 
> I checked the JaCoCo official webpage for offline instrumentation but 
> didn't understand the process properly. I would be really grateful if 
> someone can give a step by step procedure to do the JaCoCo offline 
> instrumentation in Android. 
> A blog post on this topic would be really helpful to the new users.
>
> Thank you!
>
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to jac...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jacoco/142163e8-fe60-4a0a-8f41-e186ee1c51d8%40googlegroups.com
>  
> 
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jacoco+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/5113efe9-9b9e-4ef3-b519-6ef6588820cf%40googlegroups.com.


[java code coverage] Is there any document/blogpost describing the step by step process of JaCoCo offline instrumentation in Android

2020-01-13 Thread testerguy1232
Dear All,

I am trying to use JaCoCo to measure the coverage achieved by an automated 
testing tool that uses appium and python. 
I checked the JaCoCo official webpage for offline instrumentation but 
didn't understand the process properly. I would be really grateful if 
someone can give a step by step procedure to do the JaCoCo offline 
instrumentation in Android. 
A blog post on this topic would be really helpful to the new users.

Thank you!


-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jacoco+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/142163e8-fe60-4a0a-8f41-e186ee1c51d8%40googlegroups.com.