I've got a problem when I launch a build on Jenkins. I would like to have the coverage report of my instrumented tests in Jenkins but it is stuck while executing Jacoco Test reports.
In my Android project, I've added the line apply plugin: 'jacoco' in the app/build.gradle file. I have used,
gradle plugin version- 7.0.2
Kotlin version - 1.4.32
jacoco version - 0.8.7
build gradle - 4.2.2
Previously it was working with below mention configuration:
gradle plugin version- 6.5
Kotlin version - 1.4.32
jacoco version - 0.8.7
build gradle - 4.1.3
And I have used Robolectric and Hilt in my project and in test cases. Locally it is working fine. Only in jenkins it is getting stuck. Please help me out what I have missed.
Related
I've got a problem when I launch a build on Jenkins. I would like to have the coverage report of my instrumented tests in Jenkins but it fails due to an incompatible version of Jacoco.
In my Android project, I've added the line apply plugin: 'jacoco' in the app/build.gradle file.
My Android project use the gradle plugin 3.0.1 version.
In Jenkins, I set up my application like this:
In Jenkins, I've installed the JaCoCo plugin 3.0.1 version.
When I run a build in Jenkins with this configuration, it goes well but I don't get the coverage report of the instrumented tests.
So, I change the settings like this:
When I run a build, in the Console output, I get the following message:
ERROR: Step ‘Record JaCoCo coverage report’ aborted due to exception:
org.jacoco.core.data.IncompatibleExecDataVersionException: Cannot read execution data version 0x1006. This version of JaCoCo uses execution data version 0x1007.
On the Jenkins wiki, I read that there is a compatibility problem between different versions of Jenkins and JaCoCo: https://wiki.jenkins.io/display/JENKINS/JaCoCo+Plugin.
So, I tried to use a 7.5+ version in my Android project by adding this line in the build.gradle file:
jacoco {
toolVersion '0.7.5+'
}
But it still fails... :-(
I don't understand why it works with the *.exec files only but not when I add the *.ec files.
Someone see what I missed?
Im getting this below error after updating the gradle android plugin.
Execution failed for task ':App:jacocoTestReport'.
Unable to read execution data file app/build/outputs/code-coverage/connected/coverage.ec
jacoco version = "0.7.6.201602180812"
android plugin version: 'com.android.tools.build:gradle:2.1.0'
Is there any problem with the latest plugin?
try changing version to toolVersion = "0.7.4+". it worked for me.
I am trying to build an android project from the command line.
I am following this tutorial
My project structure and files match the tutorial exactly.
When I run gradle build it tells me that version 2.2 of gradle is required, but I have a newer version of gradle installed, 2.10. So does that mean I must download an older version of gradle to build android?
* What went wrong:
A problem occurred evaluating root project 'GradleJavaApp'.
> Failed to apply plugin [id 'com.android.application']
> Gradle version 2.2 is required. Current version is 2.10. If using the gradle wrapper, try editing the distributionUrl in H:\GradleJavaApp\gradle\wrapper\gradle-wrapper.properties to gradle-2.2-all.zip
Don't use older version of Gradle! Stick to version 2.10 (or newer).
If you followed the tutorial thoroughly,
you probably used version 1.1.3 of Android build plugin:
buildscript {
…
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
}
Build plugin version 1.1.3 is terribly outdated from the view of Android development (released on March 2015 according to the release notes).
Change that to the latest version 2.1.0.
Gradle wrapper should then stop complaining about Gradle version and
you should be able to use Gradle 2.10 normally.
Also replace all mentions of Gradle 2.3 in the tutorial with version 2.10.
In Robolectric sample project, there is no gradle plugin set up in build.gradle. For instance for AppCompat-v7
On the other hand we have Robolectric gradle plugin which as documentation says:
A Gradle plugin which enables Robolectric tests.
This plugin piggy-backs on the unit testing support added in version
1.1.0 of the Android Gradle plugin and configures the test tasks to work correctly with Robolectric.
I wonder why in Robolectric sample project there is no sign of Robolectric Gradle Plugin.
If we can run robolectric tests without the plugin in Android Studio using gradle wrapper, then what is the exact usages of Plugin?
Main reason is that this plugin isn't necessary and will be marked as deprecated if robolectric 3.0 get final. This is a statement from robolectric maintainer erd. See first answer at https://github.com/robolectric/robolectric-gradle-plugin/issues/148
I am trying to get code coverage working for a new empty Android project using Gradle in Android Studio.
I managed to get Sonar working but I can't seem to figure it out for the code coverage. (never done anything like it before)
I have looked at JaCoCo but it is not compatible with Android. The same goes for Cobertura. And it seems Emma doesn't work with Gradle yet.
I am using Gradle 1.11, Android Studio 0.5.1 and Sonar Runner 2.3
JaCoCo is now supported in Android Studio when using build tools version 0.10.0
New Build System
Release Notes:
0.10.0
....
Test code coverage support with Jacoco
Enable in the tested Build Type with testCoverageEnabled = true
HTML and XML Report generated in build/reports/coverage
Configure version of Jacoco with
android {
jacoco {
version = '0.6.2.201302030002'
}
}
Known issue: This is not compatible with using Dagger.
.....
Please refer to this answer. https://stackoverflow.com/a/25029501/973483
You should be able to use jacoco and enable code coverage on android project as long as you are using Java version 1.5. It should work with mockito, dagger and espresso.
If you, however, switch to Java 1.6 or above, you will have issues enabling code coverage