Anyone has successfully managed to make usage of t...
# kotest
a
Anyone has successfully managed to make usage of the kotest gradle plugin https://github.com/kotest/kotest-gradle-plugin to run jvm unit tests in an android kotlin simple project (not android instrumented tests in a device)? I've configured
Copy code
plugins {
    id("io.kotest") version "0.1.3"
    id("com.android.application")
    kotlin("android")
    kotlin("android.extensions")
}
in my project (single module for now, it's just to experiment with it), but when running
gradle kotest
i get
Copy code
Could not determine the dependencies of task ':app:kotest'.
> Task with path 'classes' not found in project ':app'.
gradle test
(with java5 runner) works just fine.
s
the gradle plugin is pre-release so it may not be setting up the class path properly. What's the source set name for the tests?
a
probably i'm just using it the wrong way. i've tried to run in on https://github.com/kotest/kotest repo itself (
master
branch), since i've seen it was already configured there. I've run
gradle kotest
(or alternatively with the gradle wrapper, so no risk of running unexpected versions of gradle) from the top level folder of the project, and i get
Copy code
✔ ~/kotest [master|✔]
18:13 $ ./gradlew kotest
Starting a Gradle Daemon (subsequent builds will be faster)

> Task :buildSrc:compileKotlin
The `kotlin-dsl` plugin applied to project ':buildSrc' enables experimental Kotlin compiler features. For more information see <https://docs.gradle.org/6.5.1/userguide/kotlin_dsl.html#sec:kotlin-dsl_plugin>

> Task :buildSrc:jar
:jar: No valid plugin descriptors were found in META-INF/gradle-plugins

> Configure project :
Kotlin Multiplatform Projects are an Alpha feature.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':kotest-assertions:kotest'.
> Task with path 'classes' not found in project ':kotest-assertions'.

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

* Get more help at <https://help.gradle.org>

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See <https://docs.gradle.org/6.5.1/userguide/command_line_interface.html#sec:command_line_warnings>

BUILD FAILED in 1m 22s
i suppose i'm just running it the wrong way (maybe i should run it for specific submodules?)
s
I haven't worked on it for a couple of weeks but it was JVM project only. I can't remember if I changed it to support MPP yet (probably not)
That shouldn't affect android though - I think the issue with android will be that it expects
test
sourceset and android may use
androidTest
or something ?
Are you trying to use this because junit5 doesn't work with android ?
a
nah, it was mostly for curiosity. i'm used to scalatest/spec2 bash output, i don't usually run my tests through intellij, and currently the only smooth alternative to setup a nice output in the console without having to do write some config change is to use
com.adarshr.test-logger
(which is totally fine, btw, i just wanted to experiment with the output of kotest-gradle).. the fact that i'm playing with a android project it's mostly accidental, but i've mentioned it because i was worry that could have been the root cause of the issue.. Android uses
androidTest
for instrumented tests running on the device, but i 'm not running those ATM, i'm running the unit ones, which run on jvm and are located in the
src/test
folder, however it might be that kotlin-android or gradle-android plugins interfere with the plugin
s
ok makes sense, the output is certainly better than adarshr and the built in one, because it's formatted for nested tests
👍 1
I think the issue is because the plugin tries to run classes first, but I guess classes is not a task in android projects ?
a
i didn't dig into the android gradle plugin, but yea i suspect you are right Sam, it looks like classes is defined in the java gradle plugin https://docs.gradle.org/current/userguide/java_plugin.html which is not loaded in a android project.. Not a big problem, ill try the kotest gradle plugin on a java project, and even for android projects this is one more reason to follow the (IMO great) practise of isolating the business logic of an android project in a purely java/kotlin module with no dependency on android (android can be confined in some very edge module, for purely UI or system dependencies)
thanks for your help on this, and thanks for building the gradle plugin 🙂
s
what is the classes equivilent in android