Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests filter #3

Open
sksamuel opened this issue Sep 26, 2020 · 15 comments
Open

Add tests filter #3

sksamuel opened this issue Sep 26, 2020 · 15 comments
Labels
enhancement New feature or request pinned

Comments

@sksamuel
Copy link
Member

No description provided.

@stale
Copy link

stale bot commented Nov 26, 2020

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.

@stale stale bot added the wontfix This will not be worked on label Nov 26, 2020
@stale stale bot closed this as completed Dec 3, 2020
@rezammalik
Copy link
Contributor

@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.

@sksamuel sksamuel added pinned and removed wontfix This will not be worked on labels Mar 25, 2021
@sksamuel sksamuel reopened this Mar 25, 2021
@sksamuel
Copy link
Member Author

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**

@rezammalik
Copy link
Contributor

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.

@rezammalik
Copy link
Contributor

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

@sksamuel
Copy link
Member Author

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.

@rezammalik
Copy link
Contributor

rezammalik commented Apr 14, 2021

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

@sksamuel
Copy link
Member Author

sksamuel commented Apr 14, 2021 via email

@rezammalik
Copy link
Contributor

Agreed there

@rezammalik
Copy link
Contributor

@sksamuel Like we discussed, this would be a very needed enhancement when you get a chance to get to it.

@sksamuel sksamuel added the enhancement New feature or request label Jun 14, 2021
@sksamuel
Copy link
Member Author

sksamuel commented Jun 14, 2021 via email

@hastebrot
Copy link

hastebrot commented Jan 28, 2022

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.

@sksamuel
Copy link
Member Author

Yeah the -Dkotest.filter.specs and -Dkotest.filter.tests are 5.x only.

@sksamuel
Copy link
Member Author

sksamuel commented Feb 4, 2022 via email

@rezammalik
Copy link
Contributor

Thanks for working on getting this in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned
Projects
None yet
Development

No branches or pull requests

3 participants