Eclipse - Java - Gradle is skipping jacocoTestReport - java

Project structure:
src/main/java
src/main/resources
src/test/java
Gradle version : 2.2.1
Here is my build.gradle
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
version = '1.0'
sourceCompatibility = 1.7
targetCompatibility = 1.7
test {
include 'src/test/java'
finalizedBy jacocoTestReport
}
jacoco {
toolVersion = "0.7.6.201602180812"
}
jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/reports/jacoco/html"
}
}
when I run gradle task as "test jacocoTestReport", I am getting the below results
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:jacocoTestReport SKIPPED
can someone please suggest what should be added to execute jacoco test report.
Thanks.

The task will only run if coverage data is available. You can make sure of that by also running the test task.
Source - Running jacocoReport

I was able to generate the code coverage results with the following set up.
apply plugin: 'jacoco'
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}

You can force it to run with:
jacocoTestReport {
onlyIf = {
true
}
}
This will probably give an error (there's a reason it didnt run in the first place), but the error should give more information.

Unfortunately, none of these answers worked for me.
For Spring 2.5 Users, who got stuck with it for hours -just like myself.
I had a similar issue.
I was not having the exec file generated.
And because of that ,
I found that the jacocoTestReport was simply "skipped".
I got it fixed by adding :
test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
That's because I'm using Junit5 with spring boot 2.X - Gradle 7.1
And as of today Junit5 is not invoked by default in the test task.

Late at party, but none of the answers above solved for me. Instead, changing
dependencies {
testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.0-M2'
}
to
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
}
worked like a charm (source).

Related

Spring Boot Gradle quickbuild that skips the non-essentials

Java 8 and Gradle 4.6 here. I have a Spring Boot app with the following build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.8.RELEASE")
}
}
plugins {
id 'java-library'
id 'checkstyle'
id 'jacoco'
}
apply plugin: 'org.springframework.boot'
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
configurations {
dev
}
dependencies {
compile(
,'ch.qos.logback:logback-classic:1.2.3'
,'org.slf4j:jul-to-slf4j:1.7.25'
,'org.apache.logging.log4j:log4j-to-slf4j:2.9.1'
,'org.apache.commons:commons-lang3:3.7'
,'org.springframework.boot:spring-boot-starter-actuator'
,'org.apache.commons:commons-text:1.2'
,'commons-beanutils:commons-beanutils-core:1.8.3'
)
testCompile(
'junit:junit:4.12'
,'org.mockito:mockito-core:2.23.0'
)
dev('org.springframework.boot:spring-boot-devtools')
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
String buildName = 'myapp'
jar {
baseName = buildName
}
bootRun {
if(project.hasProperty('debugMode')) {
jvmArgs = [ "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" ]
}
classpath = sourceSets.main.runtimeClasspath + configurations.dev
}
checkstyle {
toolVersion = '8.12'
ignoreFailures = false
}
jacocoTestReport {
reports {
xml.enabled false
html.enabled true
html.destination file("${buildDir}/reports/jacoco/")
}
}
check.dependsOn jacocoTestCoverageVerification
jacocoTestCoverageVerification.dependsOn jacocoTestReport
So this is a Spring Boot Java app that also uses the Checkstyle and Jacoco Gradle plugins.
I consider a "full build" to be an invocation that:
Compiles
Runs Checkstyle
Runs unit tests (JUnit)
Runs Jacoco for code coverage analysis
Uses Spring Boot's libraries to build a "fat" (self-contained) executable jar
Given my current Gradle build file, I run a full build like so:
./gradlew clean build
However this can take several minutes to run through all the unit tests and has become cumbersome. I would like to introduce a
"quick build" option that only compiles the code and creates the Spring Boot fat jar for me. This will help speed up development
time tremendously.
I'm hoping to invoke the quick build like so:
./gradlew clean quickbuild
So far I've got this:
tasks.register("quickbuild") {
doLast {
// ???
}
}
But not sure how to link the compilation and fatjar tasks to it (and more importantly; skipping all the other stuff that I don't want!). Any ideas as to what I'm missing?
Update
The bootJar task doesn't seem to exist or be configured (please check my build.gradle file provided above!):
$ ./gradlew clean bootJar
FAILURE: Build failed with an exception.
* What went wrong:
Task 'bootJar' not found in root project 'myapp'. Some candidates are: 'bootRun'.
* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
When I try to run bootRun:
$ ./gradlew clean bootRun
It tries to actually run my app! That's not what I want! I just want to compile and build the fat jar!
See documentation from the Java plugin here : https://docs.gradle.org/current/userguide/java_plugin.html#lifecycle_tasks
You could create a new task (quickbuild) and make it depend on the desired task (in your case it could be the assemble lifecycle task, I guess, or maybe bootJar task (for SpringBoot v2.x) or bootRepackage (for SpringBoot v1.5.x) )
tasks.register('quickbuild'){
dependsOn assemble
}
But if the only purpose of quickbuild task is to trigger the creation of the Jar, the simpliest solution is to execute assemble directly
./gradlew clean assemble

Custom linting rules failing with com.android.tools.build:gradle:2.3.0

My team and I develop Android apps and have decided on coding guidelines that all should follow. I therefore started implementing custom lint rules which can be found here, and have added it to our automated build process in Jenkins.
The problem we are now having is that these rules no longer work after upgrading our Android projects from
'com.android.tools.build:gradle:2.2.0' to
'com.android.tools.build:gradle:2.3.0'
We continually get the error:
java.lang.NoSuchMethodError: com.android.tools.lint.detector.api.JavaContext.getContents()Ljava/lang/String;
When switching back to gradle 2.2.0 all is fine, the custom rules are checked and the app builds.
I tried updating gradle in the lint repository and unfortunately have the exact same issue in my TodoDetector at line 72. In Android studio all dependencies are resolved fine, but when trying to build and deploy the library with ./gradlew clean build test install, We get the error listed above.
I've been searching all day and have yet to find a viable solution for this problem. Any help, tips or advice is greatly appreciated.
Terminal output
:clean
:aarWrapper:clean
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
:check
:build
:aarWrapper:preBuild UP-TO-DATE
:aarWrapper:preDebugBuild UP-TO-DATE
:aarWrapper:checkDebugManifest
:aarWrapper:prepareDebugDependencies
:aarWrapper:compileDebugAidl
:aarWrapper:compileDebugNdk UP-TO-DATE
:aarWrapper:compileLint
:aarWrapper:copyDebugLint UP-TO-DATE
:aarWrapper:mergeDebugShaders
:aarWrapper:compileDebugShaders
:aarWrapper:generateDebugAssets
:aarWrapper:mergeDebugAssets
:aarWrapper:mergeDebugProguardFiles UP-TO-DATE
:aarWrapper:packageDebugRenderscript UP-TO-DATE
:aarWrapper:compileDebugRenderscript
:aarWrapper:generateDebugResValues
:aarWrapper:generateDebugResources
:aarWrapper:packageDebugResources
:aarWrapper:processDebugManifest
:aarWrapper:generateDebugBuildConfig
:aarWrapper:processDebugResources
:aarWrapper:generateDebugSources
:aarWrapper:incrementalDebugJavaCompilationSafeguard
:aarWrapper:javaPreCompileDebug
:aarWrapper:compileDebugJavaWithJavac
:aarWrapper:processDebugJavaRes UP-TO-DATE
:aarWrapper:transformResourcesWithMergeJavaResForDebug
:aarWrapper:transformClassesAndResourcesWithSyncLibJarsForDebug
:aarWrapper:mergeDebugJniLibFolders
:aarWrapper:transformNativeLibsWithMergeJniLibsForDebug
:aarWrapper:transformNativeLibsWithStripDebugSymbolForDebug
:aarWrapper:transformNativeLibsWithSyncJniLibsForDebug
:aarWrapper:bundleDebug
:aarWrapper:compileDebugSources
:aarWrapper:assembleDebug
:aarWrapper:preReleaseBuild UP-TO-DATE
:aarWrapper:checkReleaseManifest
:aarWrapper:prepareReleaseDependencies
:aarWrapper:compileReleaseAidl
:aarWrapper:compileReleaseNdk UP-TO-DATE
:aarWrapper:copyReleaseLint UP-TO-DATE
:aarWrapper:mergeReleaseShaders
:aarWrapper:compileReleaseShaders
:aarWrapper:generateReleaseAssets
:aarWrapper:mergeReleaseAssets
:aarWrapper:mergeReleaseProguardFiles UP-TO-DATE
:aarWrapper:packageReleaseRenderscript UP-TO-DATE
:aarWrapper:compileReleaseRenderscript
:aarWrapper:generateReleaseResValues
:aarWrapper:generateReleaseResources
:aarWrapper:packageReleaseResources
:aarWrapper:processReleaseManifest
:aarWrapper:generateReleaseBuildConfig
:aarWrapper:processReleaseResources
:aarWrapper:generateReleaseSources
:aarWrapper:incrementalReleaseJavaCompilationSafeguard
:aarWrapper:javaPreCompileRelease
:aarWrapper:compileReleaseJavaWithJavac
:aarWrapper:processReleaseJavaRes UP-TO-DATE
:aarWrapper:transformResourcesWithMergeJavaResForRelease
:aarWrapper:transformClassesAndResourcesWithSyncLibJarsForRelease
:aarWrapper:mergeReleaseJniLibFolders
:aarWrapper:transformNativeLibsWithMergeJniLibsForRelease
:aarWrapper:transformNativeLibsWithStripDebugSymbolForRelease
:aarWrapper:transformNativeLibsWithSyncJniLibsForRelease
:aarWrapper:bundleRelease
:aarWrapper:compileReleaseSources
:aarWrapper:assembleRelease
:aarWrapper:assemble
:aarWrapper:lint FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':aarWrapper:lint'.
> com.android.tools.lint.detector.api.JavaContext.getContents()Ljava/lang/String;
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
gradle file
apply plugin: 'java'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
repositories {
jcenter()
}
allprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
dependencies {
compile 'com.android.tools.lint:lint:24.3.1'
compile 'com.android.tools.lint:lint-api:24.3.1'
compile 'com.android.tools.lint:lint-checks:24.3.1'
testCompile 'junit:junit:4.11'
testCompile 'org.assertj:assertj-core:3.0.0'
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile 'com.android.tools.lint:lint:24.3.1'
testCompile 'com.android.tools.lint:lint-tests:24.3.1'
testCompile 'com.android.tools:testutils:24.3.1'
}
jar {
baseName 'com.bignerdranch.linette'
version '1.0'
manifest {
attributes 'Manifest-Version': 1.0
attributes('Lint-Registry': 'com.bignerdranch.linette.registry.CustomIssueRegistry')
}
}
sourceSets {
main {
java {
srcDirs = ["lint/src/main/java"]
}
}
test {
java {
srcDirs = ["lint/src/test/java"]
}
}
}
configurations {
lintChecks
}
dependencies {
lintChecks files(jar)
}
defaultTasks 'assemble'
task install(type: Copy) {
from configurations.lintChecks
into System.getProperty('user.home') + '/.android/lint/'
}
aarWrapper gradle
apply plugin: 'com.android.library'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName '1.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
project.afterEvaluate {
def compileLint = project.tasks.getByPath(':aarWrapper:compileLint')
compileLint.dependsOn parent.tasks.getByName("jar")
compileLint << {
copy {
from '../build/libs'
into 'build/intermediates/lint'
}
}
}
If your deactivation of instant run not works then add it on your build.gradle file.
android {
lintOptions {
// if true, stop the gradle build if errors are found
abortOnError false
}
}
Then clean your project and run.
if abortOnError false not resolve your issue, then you can try the following
lintOptions {
checkReleaseBuilds false
}
Hope it will solve your issue.
Resource Link:
https://android.googlesource.com/platform/tools/base/+/e6a5b9c7c1bca4da402de442315b5ff1ada819c7
gradle build fails on lint task
Daniel Passos has given a solution here in this tutorial
Ignoring Erros
Lint is part of Gradle build process, by default if it fail your build will stop and you will get a message like it:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lint'.
> Lint found errors in the project; aborting build.
In 99% of the cases people will start ignore lint instead of fix the problems, adding this on build.gradle app
lintOptions {
abortOnError false
}
But IMHO it’s wrong. If lint is telling, you have a problem the best thing to do is fix it. Lint is a tools to make your app and the UX better.
Ignoring specific erros
Sometimes you really need to ignore some lint errors. For example, when you are using webView.getSettings().setJavaScriptEnabled(true); in your WebView
In this case, you should disable only the specific ids instead of disabling the whole lint.
lintOptions {
disable 'SetJavaScriptEnabled'
}
You also can ignore it directly in your code:
#SuppressLint "SetJavaScriptEnabled")
Or in your XML
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="SomeLintIssueIdHere" >
If you prefer you can move all your issues rules from a lint.xml file in the root directory of your project.
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="SetJavaScriptEnabled" severity="ignore" />
</lint>
I was trying out the same code and bumped into the same issue.
There are new versions available for com.android.tools.lint. Try 25.2.0 or above, and you will notice that the example code TodoDetector uses deprecated methods.
Basically, you need to make your class implement Detector.JavaPsiScanner instead of Detector.JavaScanner.
http://static.javadoc.io/com.android.tools.lint/lint-api/25.3.0/com/android/tools/lint/detector/api/Detector.JavaPsiScanner.html
I had the same error when migrating to Android Gradle plugin 2.3.0 com.android.tools.build:gradle:2.3.0. The problem in my case was that the android-apt plugin that I used has become deprecated: Android Gradle plugin 2.3.0 has annotation processing out of the box and seems to block android-apt.
Read the migration guide and migrate the "apt" section of your gradle build script and "apt" dependencies, then remove the android-apt plugin:
https://bitbucket.org/hvisser/android-apt/wiki/Migration
UPD: The problem was still there after the fix above. I looked into the error stacktrace in Event Log and found out that the exception happens in one of my custom lint checkers (io.vokal.lint:todo:1.0.3). Removing it from ~/.android/lint solved the problem.
I encountered the same issue. Looking into context.getContents():
return mDriver.getClient().readFile(file);
So i tried to do it manually like this: context.getDriver().getClient().readFile(context.file) which throws the same error message.
My workaround now is, instead of using context.getContents() i just use context.file and read it out without the driver. I am not sure if this is a good way but for me it works.
So here the working code:
static void someMethod(com.android.tools.lint.detector.api.Context context){
readFile(context.file)
...
}
static String readFile(File file) {
String path = file.getAbsolutePath();
Charset encoding = Charset.defaultCharset();
try {
byte[] encoded = Files.readAllBytes(Paths.get(path));
return new String(encoded, encoding);
} catch (IOException e){
return "";
}
}

Android - Jacoco code coverage ignores Robolectric tests

Trying to get Code coverage on my Robolectric tests in Android utilising Jacoco but it simply refuses to acknowledge my Robolectric tests when creating the reports.
My jacoco.gradle file is as follows:
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.7.6.201602180812"
}
project.afterEvaluate {
android.applicationVariants.all { variant ->
def name = variant.name
def testTaskName = "test${name.capitalize()}UnitTest"
tasks.create(name: "${testTaskName}Coverage", type: JacocoReport, dependsOn: "$testTaskName") {
group = "Reporting"
description = "Generate Jacoco coverage reports for the ${name.capitalize()} build."
classDirectories = fileTree(
dir: "${project.buildDir}/intermediates/classes/${name}",
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/*$ViewBinder*.*',
'**/BuildConfig.*',
'**/Manifest*.*']
)
sourceDirectories = files(['src/main/java'].plus(android.sourceSets[name].java.srcDirs))
executionData = files("${project.buildDir}/jacoco/${testTaskName}.exec")
reports {
xml.enabled = true
html.enabled = true
}
}
}
}
With this setup I can get Coverage reports but I get 0% coverage despite having Robolectric tests in "src/test/java".
If I add in the following code to that file:
android {
testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
}
I get the following error when Gradle tries to sync:
Error:No such property: includeNoLocationClasses for class:
org.gradle.testing.jacoco.plugins.JacocoTaskExtension_Decorated
I know that I need to have Gradle 2.13 to use this includeNoLocationClasses value so in graddle-wrapper.properties I have the following:
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-2.13-20160228000026+0000-all.zip
I am pretty certain I am running Gradle 2.13 with Android plugin version 1.5
In my apps Gradle file I have the following:
//...
apply from: 'jacoco.gradle'
//..
testOptions {
unitTests.returnDefaultValues = true
}
//...
debug {
testCoverageEnabled true
}
And the command I use to run the coverage is:
./gradlew createDebugCoverageReport
So I am wondering why I get the includeNoLocationClasses error despite using the correct Gradle version? And outside of that maybe I am doing something wrong where Jacoco isn't picking up the Robolectric tests in src/test.java ?
I don't see you build.gradle completely, but to have that flag in you have to:
Use gradle 2.13+
Use jacoco 0.7.6.201602180812
You're sure that you use gradle proper version. So, I think, the issue is only in using wrong jacoco.
Mentioning jacoco {toolVersion = "0.7.6.201602180812"} doesn't influence gradle DSL. You should add newer jacoco plugin:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.jacoco:org.jacoco.core:...'
}
}
And you should apply plugin, which you're already doing:
apply from: 'jacoco'
After such configuraiton you don't need jacoco {toolVersion = "..."} more.
Note: consider to update to newer android gradle plugin, 2.2.x is already stable. jacoco also has newer version already 0.7.7.201606060606
One more note: if you see original issue in Android Studio, check that you use wrapper by default and check that you pointed wrapper to gradle 2.13

can not create RPM using gradle

I am new to java/gradle setup and was able to build a jar file using example provided here. Also implemented Jacoco code coverage tool on same.
But running into following issue
Unable to build an RPM, Tried ospackage-plugin but its just doesnt generates anything ( used example provided on plugin's github page )
Jacoco not generating highlighted source code html files ? Its generating till method breakdown like this but not able to generate individual source code files
My build.gradle file is as below
plugins {
id "nebula.ospackage" version "3.2.0"
}
apply plugin: 'nebula.ospackage'
apply plugin: 'java'
apply plugin: "jacoco"
repositories {
mavenCentral()
jcenter()
}
dependencies {
testCompile 'org.testng:testng:6.8'
compile 'log4j:log4j:1.2.17'
}
sourceSets {
main {
java { srcDir 'src/main/java/' }
resources { srcDir 'src/main/resources' }
}
test {
java { srcDir 'src/test/java/' }
resources { srcDir 'src/test/resources' }
}
}
test {
// explicitly include or exclude tests
include 'src/test/java/**'
useTestNG{
useDefaultListeners = true
}
jacoco {
append = false
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpFile = file("$buildDir/jacoco/classpathdumps")
}
finalizedBy jacocoTestReport
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.enabled true
html.destination "${buildDir}/jacocoHtml"
}
}
jar {
baseName = 'smith'
version = '1.0'
manifest {
attributes 'Main-Class': 'src.main.java.HelloWorld '}
}
ospackage {
packageName = 'foo'
version = '1.2.3'
release = '1'
arch = I386
os = LINUX
}
// buildRpm and buildDeb are implicitly created, but can still be configured if needed
buildRpm {
arch = I386
}
The STDOUT is as following
project]$ /opt/gradle/bin/gradle build
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava
:processTestResources
:testClasses
:test
:jacocoTestReport
:check
:build
BUILD SUCCESSFUL
Total time: 11.258 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.9/userguide/gradle_daemon.html
Any pointers on whatever i am overlooking above will be highly appreciated.
Also feel free to let me know in case any standard/convention is not followed
Thanks
You need to run the buildRpm task.
gradle buildRpm
If you want this task to run when running gradle build just configure a dependency in your build.gradle file
build.dependsOn buildRpm
In addition you can add below variables in your rpm task to make your RPM more standard
requires('package name') //required package to run your RPM to be pre installed, will fail if it is not.
preInstall('path_to_file') //script to be executed before installing RPM
preUninstall('path_to_file') //script to be executed before uninstalling RPM
postInstall('path_to_file') //script to be executed after installing RPM
preUninstall('path_to_file') // script to be executed after uninstalling RPM
archiveName //the name you want to give to your RPM.
epoch //Epoch, defaults to 0
user //Default user to permission files to
permissionGroupdisplay
packageGroup
buildHost
summary
packageDescription
license
packager
distribution
vendor
url
type //type e.g. binary
//below three variables are used for signing of the RPM
signingKeyId
signingKeyPassphrase
signingKeyRingFile
sourcePackage
//if you want to include some files in your rpm
def fileToInclude = fileTree(dir:"pathToFile", include : "file" )
from (fileToInclude) {
fileMode 0500 // file level permission
into "installation Location" //locationToPlaceTheFile
}
for more details and e.g. refer this link

Running jacocoReport

I'm using Gradle 1.7 and Jacoco plugin. My project uses Java and Scala plugins.
When I run gradlew -i clean jacocoTestReport
Report is not created and I see in the log
:bl:jacocoTestReport (Thread[Daemon Thread 13,5,main] - start
:bl:jacocoTestReport
Skipping task ':bl:jacocoTestReport' as task onlyIf is false.
:bl:jacocoTestReport SKIPPED
:bl:jacocoTestReport (Thread[Daemon Thread 13,5,main]) - complete
What does it mean? Why report is not created?
The task will only run if coverage data is available. You can make sure of that by also running the test task.
Add the following at a top level to your build.gradle:
test {
finalizedBy jacocoTestReport
}
This means that at the end of the test task the jacocoTestReport task should be run.
You will receive your coverage analysis after run the tests.
None of the above worked for me. What worked for me was the following
Add to the top of my build.gradle:
apply plugin: 'jacoco' // code coverage reports
Add the following as a 'task':
// Generate code coverage reports ... run with jacoco
jacocoTestReport{
additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/reports/jacoco/html"
}
executionData = files('build/jacoco/test.exec')
}
Add the following to your gradle test task:
finalizedBy jacocoTestReport
Then I issued the following command:
gradle run test jacoco
For me the issue was that the executionData.setFrom(executionSource) file path was wrong.
For Spring 2.5 Users, who got stuck with it for hours -just like myself.
I was not having the exec file generated.
And because of that ,
I found that the jacocoTestReport was simply "skipped".
I got it fixed by adding :
apply plugin: 'jacoco'
test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
...
...
...
...
}
That's because I'm using Junit5 with spring boot 2.X
And as of today Junit5 is not by default in the test task,
Hope this helps.

Categories

Resources