I have some tests in my commonTest directory that use the built-in kotlin.test library, and some other tests in jvmTest that use io.kotlintest. I start out with a fairly vanilla build.gradle file.
If I run the jvmTest task, it executes my commonTest tests but not my jvmTest tests.
If I go back and add jvmTest.useJUnitPlatform() to my build.gradle, then run jvmTest again, it executes my jvmTest tests, but not my commonTest tests.
Basically it looks like there’s no way to configure build.gradle such that my commonTest and jvmTests run in the same execution.
To make it work you need to make the jvmTest sourceSet depend on the commonTest sourceSet. In addition you will need to add the junit implementation to the dependencies for jvmTest (the same is true for any other platform you may want to run the common tests on). Some example of how I’ve implemented it is here:
Thanks…I tried adding dependsOn commonTest to my jvmTest.dependencies block, but unfortunately this seemed not to work for me. The junit implementation was already present in jvmTest:
Seems it wasn’t working because there was no (junit) TestEngine to pick up the commonTest-style tests. Not sure how that was ever working, even before kotlintest. Anyway, this works
I have similar problems with running tests in multiplatform project. Documentation is very poor I cannot figure out where is the problem – Would appreciate any help.
What went wrong:
Execution failed for task ‘:ModuleA:jvmTest’.
No tests found for given includes: [module_a.SomeClassTest.testSomeFun](filter.includeTestsMatching)
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.