kotest / kotest-gradle-plugin

A gradle plugin for Kotest
https://kotest.io
Apache License 2.0
30 stars 5 forks source link

Collecting of coverage value using plugin #15

Closed roomanidzee closed 3 years ago

roomanidzee commented 3 years ago

How to preferrable collect the coverage from tests, using the kotest-gradle-plugin?

I tried to use jacoco, but after calling gradle kotest jacocoTestReport there will be an empty folder with jacoco reports.

can't send settings for reproduce , sorry.

can you help, please, with such feature?

sksamuel commented 3 years ago

jacoco is probably invoking test, I doubt it's gonna work with the gradle plugin without some custom work.

On Wed, 14 Apr 2021 at 10:14, Andrey Romanov @.***> wrote:

How to preferrable collect the coverage from tests, using the kotest-gradle-plugin?

I tried to use jacoco, but after calling gradle kotest jacocoTestReport there will be an empty folder with jacoco reports.

can't send settings for reproduce , sorry.

can you help, please, with such feature?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-gradle-plugin/issues/15, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGT627XPQ5OWZM4ADD3TIWWNPANCNFSM425TFBDA .

rezammalik commented 3 years ago

What i've done is a workaround where unit tests with coverage run via the test command and for integrations I am using kotest. This works for now for me.

sksamuel commented 3 years ago

Reading the jacoco docs, it seems like it should be relatively easy to do:

all tasks of type Test are aautomatically enhanced to provide coverage information when the java plugin has been applied

The kotest plugin uses a task of type test.

On Wed, 14 Apr 2021 at 10:27, Reza Malik @.***> wrote:

What i've done is a workaround where unit tests with coverage run via the test command and for integrations I am using kotest. This works for now for me.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-gradle-plugin/issues/15#issuecomment-819607157, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGU7NGPZDQR2JRNXE4LTIWX4XANCNFSM425TFBDA .

sksamuel commented 3 years ago

tasks.create("testtypes") { tasks.withType { println("hello $this") } }

Configure project : hello task ':kotest' hello task ':test'

So Kotest is being picked up properly as a "Test" type.

From jacoco:

https://github.com/gradle/gradle/blob/master/subprojects/jacoco/src/main/java/org/gradle/testing/jacoco/plugins/JacocoPlugin.java#L134-L136

So.... it might be as simple as making sure the jacoco plugin runs AFTER kotest. My guess is they run in alphabetical order?

On Wed, 14 Apr 2021 at 10:31, Stephen Samuel (Sam) @.***> wrote:

Reading the jacoco docs, it seems like it should be relatively easy to do:

all tasks of type Test https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html are automatically enhanced to provide coverage information when the java plugin has been applied

The kotest plugin uses a task of type test.

On Wed, 14 Apr 2021 at 10:27, Reza Malik @.***> wrote:

What i've done is a workaround where unit tests with coverage run via the test command and for integrations I am using kotest. This works for now for me.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-gradle-plugin/issues/15#issuecomment-819607157, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGU7NGPZDQR2JRNXE4LTIWX4XANCNFSM425TFBDA .

roomanidzee commented 3 years ago

probably yes, in alphabetical order

there should be some additional config in build.gradle.kts, or it should just work like this: gradle kotest jacocoTestReport ?

tasks.create("testtypes") { tasks.withType { println("hello $this") } } Configure project : hello task ':kotest' hello task ':test' So Kotest is being picked up properly as a "Test" type. From jacoco: https://github.com/gradle/gradle/blob/master/subprojects/jacoco/src/main/java/org/gradle/testing/jacoco/plugins/JacocoPlugin.java#L134-L136 So.... it might be as simple as making sure the jacoco plugin runs AFTER kotest. My guess is they run in alphabetical order? On Wed, 14 Apr 2021 at 10:31, Stephen Samuel (Sam) @.> wrote: Reading the jacoco docs, it seems like it should be relatively easy to do: all tasks of type Test https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html are automatically enhanced to provide coverage information when the java plugin has been applied The kotest plugin uses a task of type test. On Wed, 14 Apr 2021 at 10:27, Reza Malik @.> wrote: > What i've done is a workaround where unit tests with coverage run via the > test command and for integrations I am using kotest. This works for now for > me. > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <#15 (comment)>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AAFVSGU7NGPZDQR2JRNXE4LTIWX4XANCNFSM425TFBDA > . >

sksamuel commented 3 years ago

I don't use jacoco myself, but we could create a sample project I suppose.

I think you might have to declare them in alphabetical order in your build (not the order you run them at the CLI).

On Wed, 14 Apr 2021 at 10:45, Andrey Romanov @.***> wrote:

probably yes, in alphabetical order

there should be some additional config in build.gradle.kts, or it should just work like this: gradle kotest jacocoTestReport ?

tasks.create("testtypes") { tasks.withType { println("hello $this") } } Configure project : hello task ':kotest' hello task ':test' So Kotest is being picked up properly as a "Test" type. From jacoco: https://github.com/gradle/gradle/blob/master/subprojects/jacoco/src/main/java/org/gradle/testing/jacoco/plugins/JacocoPlugin.java#L134-L136 So.... it might be as simple as making sure the jacoco plugin runs AFTER kotest. My guess is they run in alphabetical order? … <#m2525221493023811523> On Wed, 14 Apr 2021 at 10:31, Stephen Samuel (Sam) @.> wrote: Reading the jacoco docs, it seems like it should be relatively easy to do: all tasks of type Test https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html are automatically enhanced to provide coverage information when the java plugin has been applied The kotest plugin uses a task of type test. On Wed, 14 Apr 2021 at 10:27, Reza Malik @.> wrote: > What i've done is a workaround where unit tests with coverage run via the > test command and for integrations I am using kotest. This works for now for > me. > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <#15 (comment) https://github.com/kotest/kotest-gradle-plugin/issues/15#issuecomment-819607157>,

or unsubscribe > https://github.com/notifications/unsubscribe-auth/AAFVSGU7NGPZDQR2JRNXE4LTIWX4XANCNFSM425TFBDA . >

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-gradle-plugin/issues/15#issuecomment-819620913, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGQNC5FFDINXN4WIIATTIW2DJANCNFSM425TFBDA .

roomanidzee commented 3 years ago

@sksamuel will be very great, thank you!

rezammalik commented 3 years ago

This would be a nice feature for me too where I can run everything via kotest instead of test and then filter the unit tests using our other tag feature.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.