Closed NinoDLC closed 1 year ago
Hi, may you clarify which language is used for writing scripts, Groovy or Kotlin?
Groovy !
This very issue is mentioned in migration guide: https://github.com/Kotlin/kotlinx-kover/blob/main/docs/migration-to-0.6.0.md#type-of-isdisabled-property-changed-from-boolean-to-propertyboolean
You have to use isDisabled.set(true)
instead
Hello @qwwdfsad, it seems you answered and closed the wrong issue. I already tried to use isDisabled.set(true)
(or false), as I said in my initial message.
My bad, thanks!
@NinoDLC, does disabling a task in this way solve your problem?
In the module's build.gradle
, you need to add
kover {
// ...
instrumentation {
excludeTasks.add "testDebugUnitTest"
}
}
and delete unitTests.all { ... }
I am having the same problem. @shanshin
I think he wants to enable kover not exclude it. Or do I get your answer wrong?
And when I try your suggestion I get the following error:
Cannot set the value of read-only property 'excludeTasks' for object of type kotlinx.kover.api.KoverProjectInstrumentation.
@thekie, sorry, this was an example for build.gradle.kts
, for Groovy try
kover {
// ...
instrumentation {
excludeTasks.add "testDebugUnitTest"
}
}
If I put
kover {
instrumentation {
excludeTasks.add "testDebugUnitTest"
}
}
inside my build.gradle (module) and then I run ./gradlew koverHtmlReport
, nothing happen. Not a single line is printed in the console, only "BUILD SUCCESSFUL in 791ms".
If you want to check my project (which works with 0.5.0 but won't work at all with 0.6.0), here's the commit I tried for implementing 0.6.0 : https://github.com/NinoDLC/OpenClassrooms_P5_TodoK_Example/compare/master...kover_dot_six_integration
@NinoDLC, please refer to migration guide in order to migrate to 0.6.0.
For your case applying the plugin to the root project no longer causes it to be recursively applied to all subprojects - you must explicitly apply it to all projects that will be covered
: if you want to generate HTML report for app
module you sholud apply kover plugin in it.
Also note that merged tasks are no longer created by default.
It works, finally.
For future googlers (and gradle noobs like me 😁), please be advised that :
1/ Android projects are "multi project" (even with only one "app" module), so basically "app" is a subproject. Android is always "multi project" I guess ?
2/ With 0.5.0, for an Android project, you could generate your report with ./gradlew koverHtmlReport
. Now, you have to use ./gradlew koverMergedHtmlReport
instead. Also, if you re-run this task, it won't print anything to the console anymore. I don't know if it's intended or not. Finally, ./gradlew koverHtmlReport
still works but won't apply the filters you put in the project build.gradle. Once again, I don't know if it's intended or not.
Example of Kover migration from 0.5.0 to 0.6.0 on Android available here : https://github.com/NinoDLC/OpenClassrooms_P5_TodoK_Example/commit/2f3046d1f965e3cce9fe3a1765db6538fd742272
Finally, ./gradlew koverHtmlReport still works but won't apply the filters you put in the project build.gradle. Once again, I don't know if it's intended or not.
The task is created in each project (module) in which the plugin is applied. Filters from one module do not affect reports in the other. If your tests are located in the app
module, then you need to add filters to the file build.gradle
of this app
module
Also, if you re-run this task, it won't print anything to the console anymore.
When restarting, the task is not executed, and the report is taken from the build cache, so a message is not printed to the console that the report has been generated. Perhaps you should always print such a message.
For the record, here's the kover migration 0.5.0 to 0.6.0 in gradle.kts style : https://github.com/NinoDLC/OpenClassrooms_P5_TodoK_Example/commit/e300478e02a1ee0b518778f87c5a2d6138997fa6
I followed the guide on the README for Android (a bit under https://github.com/Kotlin/kotlinx-kover#configuring-jvm-test-task), so I get:
build.gradle (project):
build.gradle (module):
On sync, it gets an exception :
I tried
disabled.set(false)
,isDisabled = false
,isDisabled.set(false)
, to no avail.enabled = true
doesn't produce an exception, but running./gradlew koverHtmlReport
doesn't output anything in the console, nor it creates any files...I'm quite lost, how do I make Kover 0.6.0 work for Android ?