what is the proper way to use `kotest M5`? I am fo...
# kotest
a
what is the proper way to use
kotest M5
? I am following this now https://github.com/JesusMcCloud/KMPotest/blob/main/shared/build.gradle.kts#L10-L16 but when try using
./gradlew test
then I only get information like this
Copy code
package.extensions.DoubleExtensionsTest > should format numbers into abbreviated form FAILED
    io.kotest.assertions.AssertionFailedError at DoubleExtensionsTest.kt:9
is this expected? I also try to run individual using kotest plugin in intellij but get error
Copy code
Cannot locate tasks that match ':iosSimulatorArm64Kotest' as task 'iosSimulatorArm64Kotest' not found in root project 'PostMobile'.
and I am tried this as well https://github.com/kotest/kotest/issues/4936#issuecomment-3067960857 but not working as well. I maybe missing something?
b
reports are currently broken on non-jvm targets, but this is being worked on. if you are using jvm-only. add the junit runner and you should get reports. I am also having trouble resolving artefacts (even though they were published dafter #4936 was opened
a
is there any easy way to just run kotest in jvm only? both working with intellij plugin and from cli? I am new to kotlin environment so not understand the gradle. here is my dependencies
Copy code
commonTest.dependencies {
      implementation(libs.kotest.assertions.core)
      implementation(libs.kotest.framework.engine)
      implementation(libs.kotest.property)
      implementation(libs.turbine)
      implementation(libs.kotlinx.coroutines.test)
    }

    androidMain.dependencies {
      implementation(libs.ktor.client.okhttp)
      implementation(libs.grpc.okhttp)
    }
    iosMain.dependencies {
      implementation(libs.ktor.client.darwin)
    }

    androidUnitTest {
      dependencies {
        implementation(libs.kotest.runner.junit5)
        implementation(libs.kotest.assertions.core)
        implementation(libs.kotest.framework.engine)
      }
      tasks.withType<Test>().configureEach {
        useJUnitPlatform()
        finalizedBy(tasks.named(jacocoTestReport))
      }
    }
or I just need to move all kotest in
commonTest.dependencies
to
androidUnitTest.dependencies
?
b
if you want multiplatform reporting, check out this weekens's commits here. Until Sam integrates this concept into Kotest proper, you'll have to resort to a custom kotest spec that adds a custom reporter and some gradle foo to wire the ksp dependencies and copy the test results
jvm should just work. add the junit5 runner and you're golden
a
I already add junit5 runner on
androidUnitTest.dependencies
like that but now not really sure how to force it to run jvm only
b
Update on the non-availalbe artefacts: was a misconfig.
kotest-framework-api
is not a thing anymore
i don't follow
a
hmm... I still have some failed build on my ios project but want to run the test only on jvm but not really sure how to do it. Because if I click this then it will tell my ios project can't be build even though I only want to run for jvm only now...
`./gradlew test `can be buidl tho even tho it is just saying
Copy code
package.extensions.DoubleExtensionsTest > should format numbers into abbreviated form FAILED
    io.kotest.assertions.AssertionFailedError at DoubleExtensionsTest.kt:9
hmm.. nvm. looks like I need to make it can build for ios first
b
it is just an android unit test, not an instrumented test, right?
a
yeah. I have unit test in
commonTest
folder. And I run
./gradlew check
in root project but the error is just
Copy code
package.extensions.DoubleExtensionsTest > should format numbers into abbreviated form FAILED
    io.kotest.assertions.AssertionFailedError at DoubleExtensionsTest.kt:9
iirc, usually it should have something like also print expected and actual value?
b
our setup typically works with the following source layout: •
androidJvmMain
combined android and JVM sources •
jvmMain
jvm-only (non-android) •
androidMain
Android only
the junit runner is part of the jvm test sources (jvm and android srouces depend on the androidjvmMain source set). junit tests are run on the jvm only, android-specific tests are run as instrumented test, this way we get to run only the android-specific in an environmetn that actually behaves android-specific
we do rely on an external runner to wire kotest to junit for the instrumented tests though: https://github.com/LeoColman/kotest-android
a
my setup is typical kotlin multiplatform setup •
androidMain
as Android only and also actual class from
commonMain
iosMain
as iOS only and also actual class from
commonMain
commonMain
shared logic between android and iOS •
commonTest
unit tests for testing logic in
commonMain
.
commonTest
is usually the one that we wrote unit test. For unit test we usually just run
./gradlew test
to make sure it pass.
b
just for kicks: what happens it you add the junit runner to the jvmTest sources?
a
still the same issue. but I do wonder is this expected when failing in kotest it is just showing
failed
without printing expected and actual?
b
Then I am also at a loss. Sorry
a
no worries. thanks for the help 😄