kotest-gradle-plugin
kotest-gradle-plugin copied to clipboard
Add tests filter
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.
@sksamuel similar to the tag request, a filter would be really helpful. the exclude / filter options on the test task only work for me if I use Junit but I really would prefer using this plugin.
This is easy to do, but we need to consider what syntax to use.
Gradle style perhaps:
entire spec
--tests a.b.SpecName
or specific test path
--tests a.b.SpecName mytest**
or
--include a.b.SpecName mytest**
--exclude a.b.SpecName mytest**
I prefer the gradle style commands with filtering by class name personally. A specific test would be super cool because then I don't have to do the f: thingy to focus for each test in code when I am debugging. The first one to run a specific spec is also helpful.
Retaining this functionality would be nice if it is not too much work:
https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/TestFilter.html
Yeah that's what I was thinking. The gradle one isn't great as it uses a ClassMethodFilter internally which assumes the test name is a method handle.
Ah gotcha. The killer feature is the specific test within a spec.
How hard is it to do a line number run? Like in ruby they have this thing where you can call File:<line number>
and it will run the containing test. Just a thought and maybe not even something thats possible
Line number is possible, but I think the test path is sufficient
--include a.b.Spec full name of test here (or wilcard).
On Wed, 14 Apr 2021 at 11:32, Reza Malik @.***> wrote:
Ah gotcha. The killer feature is the specific test within a spec.
How hard is it to do a line number run? Like in ruby they have this thing where you can call File: and it will run the containing test. Just a thought and maybe not even something thats possible
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-gradle-plugin/issues/3#issuecomment-819654696, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGQHJ4XKZO5LJLT3ORLTIW7SNANCNFSM4R3DNLXQ .
Agreed there
@sksamuel Like we discussed, this would be a very needed enhancement when you get a chance to get to it.
It will go into 5.0
On Mon, 14 Jun 2021 at 10:24, Reza Malik @.***> wrote:
@sksamuel https://github.com/sksamuel Like we discussed, this would be a very needed enhancement when you get a chance to get to it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-gradle-plugin/issues/3#issuecomment-860774188, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGVWCX4O3Y25D4H4JO3TSYNL7ANCNFSM4R3DNLXQ .
Test filtering works well using the Kotest plugin for IntelliJ. The "Kotest" tool window uses the current editor view to show the opened spec class with a list of its test paths. You can use it to create a new Kotest run configuration which allows to configure "Test Path", "Spec Class", and "Package". It used these values and passes them to the kotest engine language entry point, e.g. io.kotest.engine.launcher.MainKt --package my.package.com --spec my.package.com.MySpec --testpath test path --reporter teamcity
It seems the Kotest Gradle plugin also uses this entry point but does not pass these arguments.
There is a guide page [1] that lists Kotest specific test filtering parameters -Dkotest.filter.specs
and -Dkotest.filter.tests
. I tested using these parameters but could not make them work. It's maybe caused when test
forks the JVM and does not propagate the -D
arguments passed to gradle to the test.
[1] https://kotest.io/docs/framework/conditional/conditional-tests-with-gradle.html
Update:
Filtering for package and spec class worked for me using ./gradlew test --tasks
:
$ ./gradlew test --tests "my.package.com*"
$ ./gradlew test --tests "*MySpec"
However using plugins { id("io.kotest") version "0.3.8" }
and Gradle 7.3.2 it will ignore my test filters and run all tests when I use the kotest
gradle task, e.g. ./gradle kotest --tests "*MySpec"
.
Another update:
Argh, we still use Kotlin 1.5.30 and Kotest 4.6.4. Have to update to Kotlin 1.6.x and Kotest 5.x.x in the future.
Yeah the -Dkotest.filter.specs and -Dkotest.filter.tests are 5.x only.
Yes it's available in 5. So we can update this now.
On Fri, 4 Feb 2022 at 15:15, Reza Malik @.***> wrote:
@sksamuel https://github.com/sksamuel Did this already make it into 5.x?
— Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-gradle-plugin/issues/3#issuecomment-1030354528, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGUL2WUADTHDUJPDJFTUZQ6VHANCNFSM4R3DNLXQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you were mentioned.Message ID: @.***>
Thanks for working on getting this in