I'd like to use Kotest with <JUnit's Console Launc...
# kotest
s
I'd like to use Kotest with JUnit's Console Launcher, but my tests do not seem to be discovered. Has anyone made that working yet?
I'm just getting output like this:
Copy code
๐Ÿ’š Thanks for using JUnit! Support its development at <https://junit.org/sponsoring>

16:39:29.054 [main] INFO  org.ossreviewtoolkit.utils.ort.OrtProxySelector - Proxy selector was successfully installed.
โ•ท
โ””โ”€ Kotest โœ”

Test run finished after 35 ms
[         1 containers found      ]
[         0 containers skipped    ]
[         1 containers started    ]
[         0 containers aborted    ]
[         1 containers successful ]
[         0 containers failed     ]
[         0 tests found           ]
[         0 tests skipped         ]
[         0 tests started         ]
[         0 tests aborted         ]
[         0 tests successful      ]
[         0 tests failed          ]
So Kotest is found as a container, but no tests. Do I need to adjust some test pattern matcher or so?
e
Hmm.. IIRC Kotest has its own console launcher, if that's an option? What selector are you using?
s
Kotest has its own console launcher, if that's an option?
It would! My goal simple is to run the functional tests of my Kotlin application without Gradle, from a self-contained "ttest runner app".
How can I use that launcher? Is it published as a separate artifact?
What selector are you using?
None. I'm relying on defaults. But the actual problem seems to be now that the code of my funTest source set is not properly bundled. I thought I had solved that problem, but it seems to be back ๐Ÿ˜•
e
I think you would use the kotest-framework-standalone.jar, which is a fatjar pointing to the engine's standalone launcher
I haven't seen anyone doing this so not sure it works
s
Thanks, I'll have a look. But for now I struggle again to create a JAR with the source code of my tests and their dependencies.
I also just found the new kotest-framework-plugin-gradle. @sam is that a plugin that can create a stand-alone test runner for a specific test source set?
s
It's tied into the test source set. Do you want to run tests from a main method rather than through gradle at all?
s
Yes, exactly. Basically, like creating an "executable JAR" like via the Gradle application plugin, except that it doe snot run my app, but my functional tests for the app, on any machine without Gradle or the source code of my app.
a
@Sebastian Schuberth i have been using the junit console launcher to run a set of kotest tests standalone. I have tried to collect the relevant configuration snippets: build.gradle.kts:
Copy code
plugins {
    // we use the gradle application plugin to build an application
    application

    ...
 }

dependencies {
    // all kotest dependencies go to implementation to ensure they get packaged in the application
    implementation(platform(libs.junit.bom))
    implementation(libs.bundles.kotest)

    runtimeOnly(libs.bundles.slf4j)
    implementation("org.junit.platform:junit-platform-console-standalone:1.8.2")
}
with this gradle config a jar containing the tests is created. We package this + the dependency jars into a docker image. In the docker script we execute this command to run the tests:
Copy code
java $JAVA_PROPS \
  --add-opens=java.base/sun.nio.fs=ALL-UNNAMED \
  -cp /app/resources:/app/classes:/app/libs/* \
  org.junit.platform.console.ConsoleLauncher \
  --disable-banner \
  --scan-class-path \
  --fail-if-no-tests \
  --include-classname='.*Test.*' \
  --reports-dir reports
Hope this helps
s
Thanks @abendt, I was successful by now using the approach from
kotest-framework-standalone
with the
io.kotest.engine.launcher.MainKt
entry point.
๐Ÿ‘๐Ÿพ 1