Gradle: android plugin does not generate jacoco.exe when used testDebugCoverage = true

1,339 views
Skip to first unread message

tvijay

unread,
Sep 8, 2014, 9:52:25 AM9/8/14
to adt...@googlegroups.com
I enabled jacoco code coverage using following code to build file

buildTypes {
debug { testCoverageEnabled true }
}

test are running and reports are generated "buildDir/ouptuts/reports/coverage/".
But I require the path to generated jacoco.exe so that i can sync the reports to SONARQUBE server.

Configurations:
Gradle version: 1.11
Android Gradle plugin:0.11.+
Emulator: Android-19
App Target SDK :19

my logcat gives me below information when i run "connectedCheck" 

java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
  at libcore.io.IoBridge.open(IoBridge.java:409)
  at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
  at org.jacoco.agent.rt.internal_932a715.output.FileOutput.openFile(FileOutput.java:67)
  at org.jacoco.agent.rt.internal_932a715.output.FileOutput.startup(FileOutput.java:49)
  at org.jacoco.agent.rt.internal_932a715.Agent.startup(Agent.java:122)
  at org.jacoco.agent.rt.internal_932a715.Agent.getInstance(Agent.java:50)
  at org.jacoco.agent.rt.internal_932a715.Offline.<clinit>(Offline.java:31)
  at com.example.myandroid.SampleObject.$jacocoInit(SampleObject.java)
  at com.example.myandroid.SampleObject.<init>(SampleObject.java)
  at com.example.myandroid.tests.MyAndroidAppActivityTest.testRunIt(MyAndroidAppActivityTest.java:20)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:515)
  at junit.framework.TestCase.runTest(TestCase.java:168)
  at junit.framework.TestCase.runBare(TestCase.java:134)
  at junit.framework.TestResult$1.protect(TestResult.java:115)
  at junit.framework.TestResult.runProtected(TestResult.java:133)
  at junit.framework.TestResult.run(TestResult.java:118)
  at junit.framework.TestCase.run(TestCase.java:124)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
  at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
  at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
    Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only file system)
  at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
  at libcore.io.IoBridge.open(IoBridge.java:393)
  ... 21 more

Xavier Ducrohet

unread,
Sep 11, 2014, 9:45:44 PM9/11/14
to adt...@googlegroups.com
This error is happening on the device. This is probably not where you want to do any syncing with a CI server.

The Gradle plugin manually grabs the code coverage data, and you should plug yourself there (through a custom plugin) to send that somewhere if you need to.

TBH I'm not sure we have the proper hooks for that, but if we can figure out what you need, we can add it easily.

--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

tvijay

unread,
Sep 15, 2014, 2:44:41 AM9/15/14
to adt...@googlegroups.com

Thanks Xavier.

JFYI, 
My objective is to setup build-job at jenkins to build, test, generate test reports and code-coverage reports through gradle build and then sync the generated reports/data with SONARQUBE.

I am running tests on emulator (target: android-19).

-- I have setup build job at jenkins-CI server. 
-- I have also setup SONARQUBE with Android plugin. 
-- I have also enabled test coverage in build files
-- Build files is configured with all required sonar properties.


        sonarRunner {
                sonarProperties {
                    //...
                    property 'sonar.language', 'java'
                    property 'sonar.sources', 'src'
                    property 'sonar.binaries', 'build/intermediates/classes/debug/'
                    property 'sonar.junit.reportsPath', 'build/outputs/androidTest-results/connected/'
                    property 'sonar.java.codeCoveragePlugin', 'jacoco'
                    property 'sonar.jacoco.reportPath' , 'build/outputs/code-coverage/connected/'
                    property 'sonar.profile', 'Android Lint'
                }
        }


On running 'connectedCheck'
-- HTML formatted reports for both test results and code coverage get generated but to sync the reports-data with sonarQube I do require the location to generated 'jacoco.exe' (coverage data)
   which I do not see at 'build/outputs/code-coverage/connected/', though I am able to see html reports.

Xavier Ducrohet

unread,
Sep 15, 2014, 1:18:05 PM9/15/14
to adt...@googlegroups.com
We don't generate jacoco.exe

tvijay

unread,
Oct 16, 2014, 11:04:01 AM10/16/14
to adt...@googlegroups.com
'jacoco.exe' is just the name.
I am actually asking about the file containing the coverage data (or raw coverage data) that can be used to 
 -- Parse and generage HTML/XML based reports (I know gradle already does it)

But one another use of the coverage file is that it is been expected by SONAR RUNNER, so that sonar runner parses the file and push the report data to server server.

Sorry, If i am confusing you but I just want to sync those coverage reports with sonar server. Is it possible.

narayanan swaminathan

unread,
Mar 9, 2016, 12:58:14 PM3/9/16
to adt-dev
Hi I am facing the exact same problem.You got any solution?

I have created coverage.ec file using jacoco.I want to sync the report to sonar server.

Thanks
Narayanan
Reply all
Reply to author
Forward
0 new messages