https://kotlinlang.org logo
#kotest
Title
# kotest
b

bbaldino

05/16/2022, 6:40 PM
I’m getting
No tests found for given includes
when trying to run a single kotest test inside a gradle project--I assume this must be something dumb I’m missing but after googling around a bit I still haven’t seen anything that addresses it. I do have
Copy code
tasks.withType<Test>().configureEach {
    useJUnitPlatform()
}
in build.gradle.kts
./gradlew tests -i
doesn’t appear to run anything either (and intellij is set to use gradle to run tests).
s

sam

05/17/2022, 3:30 PM
what deps do you have ?
b

bbaldino

05/17/2022, 3:30 PM
io.kotest:kotest-runner-junit5:5.3.0
s

sam

05/17/2022, 3:31 PM
that should be allyou need
this a new project or just stopped working ?
b

bbaldino

05/17/2022, 3:31 PM
this is a new project, just adding kotest
s

sam

05/17/2022, 3:31 PM
what is tests -i ?
./gradlew check
will run all tests
b

bbaldino

05/17/2022, 3:32 PM
test -i is: (big block incoming)
Copy code
bbaldino@BBALDINO-M-8A1Z sessions % ./gradlew test -i
Initialized native services in: /Users/bbaldino/.gradle/native
Initialized jansi services in: /Users/bbaldino/.gradle/native
Removing 0 daemon stop events from registry
Starting a Gradle Daemon (subsequent builds will be faster)
Starting process 'Gradle build daemon'. Working directory: /Users/bbaldino/.gradle/daemon/7.3.3 Command: /usr/local/Cellar/openjdk@11/11.0.10/libexec/openjdk.jdk/Contents/Home/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /Users/bbaldino/.gradle/wrapper/dists/gradle-7.3.3-bin/6a41zxkdtcxs8rphpq6y0069z/gradle-7.3.3/lib/gradle-launcher-7.3.3.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 7.3.3
Successfully started process 'Gradle build daemon'
An attempt to start the daemon took 1.387 secs.
The client will now receive all logging from the daemon (pid: 68986). The daemon log file: /Users/bbaldino/.gradle/daemon/7.3.3/daemon-68986.out.log
Starting build in new daemon [memory: 512 MiB]
Using 8 worker leases.
Watching the file system is configured to be enabled if available
Now considering [/Users/bbaldino/work/sessions] as hierarchies to watch
File system watching is active
Starting Build
Skipping Kotlin DSL script compilation (Settings/TopLevel/stage1) as it is up-to-date.
Settings evaluated using settings file '/Users/bbaldino/work/sessions/settings.gradle.kts'.
Projects loaded. Root project using build file '/Users/bbaldino/work/sessions/build.gradle'.
Included projects: [root project 'sessions', project ':sessions-service']

> Configure project :
Evaluating root project 'sessions' using build file '/Users/bbaldino/work/sessions/build.gradle'.

> Configure project :sessions-service
Evaluating project ':sessions-service' using build file '/Users/bbaldino/work/sessions/sessions-service/build.gradle.kts'.
Caching disabled for Kotlin DSL plugin accessors for classpath '12d94f928b3a8d08ab323c90e05cf87b' because:
  Build cache is disabled
Skipping Kotlin DSL plugin accessors for classpath '12d94f928b3a8d08ab323c90e05cf87b' as it is up-to-date.
Caching disabled for Kotlin DSL script compilation (Project/TopLevel/stage1) because:
  Build cache is disabled
Skipping Kotlin DSL script compilation (Project/TopLevel/stage1) as it is up-to-date.
kotlin scripting plugin: created the scripting discovery configuration: kotlinScriptDef
kotlin scripting plugin: created the scripting discovery configuration: testKotlinScriptDef
Caching disabled for Kotlin DSL accessors for project ':sessions-service' because:
  Build cache is disabled
Skipping Kotlin DSL accessors for project ':sessions-service' as it is up-to-date.
Caching disabled for Kotlin DSL script compilation (Project/TopLevel/stage2) because:
  Build cache is disabled
Skipping Kotlin DSL script compilation (Project/TopLevel/stage2) as it is up-to-date.
All projects evaluated.
Selected primary task 'test' from project :
Tasks to be executed: [task ':sessions-service:compileKotlin', task ':sessions-service:compileJava', task ':sessions-service:processResources', task ':sessions-service:classes', task ':sessions-service:compileTestKotlin', task ':sessions-service:compileTestJava', task ':sessions-service:processTestResources', task ':sessions-service:testClasses', task ':sessions-service:test']
Tasks that were excluded: []
:sessions-service:compileKotlin (Thread[Execution worker for ':' Thread 4,5,main]) started.

> Task :sessions-service:compileKotlin UP-TO-DATE
Watching 1 directory hierarchies to track changes
Caching disabled for task ':sessions-service:compileKotlin' because:
  Build cache is disabled
Skipping task ':sessions-service:compileKotlin' as it is up-to-date.
:sessions-service:compileKotlin (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 0.646 secs.
:sessions-service:compileJava (Thread[Execution worker for ':' Thread 4,5,main]) started.

> Task :sessions-service:compileJava NO-SOURCE
file or directory '/Users/bbaldino/work/sessions/sessions-service/src/main/java', not found
Skipping task ':sessions-service:compileJava' as it has no source files and no previous output files.
:sessions-service:compileJava (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 0.003 secs.
:sessions-service:processResources (Thread[Execution worker for ':' Thread 4,5,main]) started.

> Task :sessions-service:processResources UP-TO-DATE
Caching disabled for task ':sessions-service:processResources' because:
  Build cache is disabled
Skipping task ':sessions-service:processResources' as it is up-to-date.
:sessions-service:processResources (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 0.008 secs.
:sessions-service:classes (Thread[Execution worker for ':' Thread 4,5,main]) started.

> Task :sessions-service:classes UP-TO-DATE
Skipping task ':sessions-service:classes' as it has no actions.
:sessions-service:classes (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 0.0 secs.
:sessions-service:compileTestKotlin (Thread[Execution worker for ':' Thread 4,5,main]) started.

> Task :sessions-service:compileTestKotlin UP-TO-DATE
Caching disabled for task ':sessions-service:compileTestKotlin' because:
  Build cache is disabled
Skipping task ':sessions-service:compileTestKotlin' as it is up-to-date.
:sessions-service:compileTestKotlin (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 0.133 secs.
:sessions-service:compileTestJava (Thread[Execution worker for ':' Thread 4,5,main]) started.

> Task :sessions-service:compileTestJava NO-SOURCE
file or directory '/Users/bbaldino/work/sessions/sessions-service/src/test/java', not found
Skipping task ':sessions-service:compileTestJava' as it has no source files and no previous output files.
:sessions-service:compileTestJava (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 0.002 secs.
:sessions-service:processTestResources (Thread[Execution worker for ':' Thread 4,5,main]) started.

> Task :sessions-service:processTestResources NO-SOURCE
file or directory '/Users/bbaldino/work/sessions/sessions-service/src/test/resources', not found
Skipping task ':sessions-service:processTestResources' as it has no source files and no previous output files.
:sessions-service:processTestResources (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 0.001 secs.
:sessions-service:testClasses (Thread[Execution worker for ':' Thread 4,5,main]) started.

> Task :sessions-service:testClasses UP-TO-DATE
Skipping task ':sessions-service:testClasses' as it has no actions.
:sessions-service:testClasses (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 0.0 secs.
:sessions-service:test (Thread[Execution worker for ':' Thread 4,5,main]) started.

> Task :sessions-service:test UP-TO-DATE
file or directory '/Users/bbaldino/work/sessions/sessions-service/build/classes/java/test', not found
Caching disabled for task ':sessions-service:test' because:
  Build cache is disabled
Skipping task ':sessions-service:test' as it is up-to-date.
:sessions-service:test (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 0.098 secs.

BUILD SUCCESSFUL in 9s
4 actionable tasks: 4 up-to-date
Watched directory hierarchies: [/Users/bbaldino/work/sessions]
s

sam

05/17/2022, 3:32 PM
I mean like what is tests -i supposed to do ?
b

bbaldino

05/17/2022, 3:33 PM
oh, ha
s

sam

05/17/2022, 3:33 PM
is tests even a gradle command ?
b

bbaldino

05/17/2022, 3:33 PM
i’m new to gradle, so i saw “tests” in
gradlew tasks
and figured it would be worth trying 🙂
check:
Copy code
bbaldino@BBALDINO-M-8A1Z sessions % ./gradlew check

BUILD SUCCESSFUL in 6s
11 actionable tasks: 5 executed, 6 up-to-date
s

sam

05/17/2022, 3:33 PM
there's
test
and
check
test is JVM only, check is MPP
but check runs test so you can alwys use it
b

bbaldino

05/17/2022, 3:34 PM
ah yes, sorry
test
is what i meant (and what i ran, just a typo here)
s

sam

05/17/2022, 3:34 PM
you prob are missing some test setup in your build file
b

bbaldino

05/17/2022, 3:34 PM
it’s a multi-module project, so maybe i am missing something there.
i have
Copy code
tasks.withType<Test>().configureEach {
    useJUnitPlatform()
}
in the submodule…do i need something at the top level as well?
s

sam

05/17/2022, 3:34 PM
Copy code
allprojects {
   apply(plugin = "org.jetbrains.kotlin.jvm")

   repositories {
      mavenCentral()
      mavenLocal()
   }

   dependencies {
        testImplementation("io.kotest:kotest-runner-junit5:5.2.3")
      testImplementation("io.kotest:kotest-assertions-core:5.2.3")
      testImplementation("io.kotest:kotest-property:5.2.3")
      testImplementation("io.kotest:kotest-framework-datatest:5.2.3")
      testImplementation("io.kotest.extensions:kotest-extensions-testcontainers:1.3.1")
      testImplementation("org.testcontainers:postgresql:1.17.1")
      testImplementation("org.testcontainers:kafka:1.17.1")
      testImplementation("io.kotest.extensions:kotest-assertions-ktor:1.0.3")
      testImplementation("io.kotest.extensions:kotest-extensions-wiremock:1.0.3")
   }

   tasks.named<Test>("test") {
      useJUnitPlatform()
      testLogging {
         showExceptions = true
         showStandardStreams = true
         exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
      }
   }
}
I do that at the top level
b

bbaldino

05/17/2022, 3:35 PM
but it’s weird that the green arrow in intellij also can’t seem to run the test
s

sam

05/17/2022, 3:35 PM
yep
that is weird
You can always use hoplite for refeerence https://github.com/sksamuel/hoplite
b

bbaldino

05/17/2022, 3:35 PM
you have that in top-level settings.gradle.kts?
ah ok, i see you have a build.gradle.kts at the top
hm, tried moving the
tasks.named<Test>...
into an
allProjects
block in a top-level build.gradle.kts, but still no luck
ok well this is weird: if i put a failing assert in the test and run it, the assert does hit. but if i remove it, i get “No tests found for given includes: [com.cisco.webex.cpaas.pvideo.logging.LogContextTest](filter.includeTestsMatching)”
./gradlew test
also shows it if there’s a failing assert
do i need
id("io.kotest") version "0.3.8"
plugin?
s

sam

05/17/2022, 3:47 PM
No
No tests found for given includes: [com.cisco.webex.cpaas.pvideo.logging.LogContextTest](filter.includeTestsMatching
if you're doing includes inside gradle it won't work
take it out
b

bbaldino

05/17/2022, 3:48 PM
i’m not doing any includes that i’m aware of
maybe it’s doing that in intellij’s run configuration for the test?
that’s what got generated from the green arrow
s

sam

05/17/2022, 3:51 PM
Hmmm
Do you have the intellij plugin
That looks like the junit plugin
b

bbaldino

05/17/2022, 3:51 PM
a kotest intellij plugin? let me check
yeah i do
but that’s the “gradle” test plugin i think
i don’t have any “run with kotest” option in the green arrow menu (not sure if that’s expected or not)
s

sam

05/17/2022, 3:56 PM
Do you have green arrow on individual tests
b

bbaldino

05/17/2022, 3:57 PM
yeah, haven’t tried those
will check
looks like that does work
and that generated a kotest run config
so i guess the issue is a class-level green arrow generated a gradle run config instead of a kotest one
s

sam

05/17/2022, 3:58 PM
yeah
must be something odd because kotest should offer an arrow on the spec class too
b

bbaldino

05/17/2022, 4:01 PM
tried deleting the existing run config and restarting intellij, but no luck. still creates a gradle run config
it’s the kotest plugin that should do that? how does it hook in to those files? the dir is marked as a test root
i tried removing the kotest and re-installing. i did see this when intellij prompted me:
(sorry i couldn’t capture the whole thing, the dumb window couldn’t be resized)
i get the same thing when i try to install manually via the marketplace
ok, upgraded intellij and then was able to get the plugin re-installed. and i think i found the issue. in preferences -> build, execution, environment -> gradle i had to change “run tests using” from “gradle” to “intellij”
s

sam

05/19/2022, 3:48 AM
The gradle should still work, it should show you kotest/gradle options. But at least you got it working.
3488 Views