Tags not working on KMP project
Version: 6.0.0.M3
Hello dear maintainers, i followed documentation for grouping tests by tags https://kotest.io/docs/framework/tags.html but it doesn't seem to work well on KMP project. Here is the command i run:
./gradlew testDebugUnitTest -Dkotest.tags="NotImportant"
There are 2 tests in Android and 2 in Main, each has one "Important" and one "NotImportant" test. I would assume only 2 test will be executed. Below is the output:
com.test.MainTest STANDARD_OUT
Main kotest.tags->: NotImportant
com.test.MainTest > Main Important PASSED
com.test.MainTest > Main NotImportant PASSED
com.test.android.AndroidTest STANDARD_OUT
Android kotest.tags->: NotImportant
com.test.android.AndroidTest > android Important PASSED
com.test.android.AndroidTest > android NotImportant PASSED
And here are the sample test for main/android.
// src/androidUnitTest
class AndroidTest : StringSpec() {
init {
println("Android kotest.tags->: ${System.getProperty("kotest.tags")}")
"android Important".config(tags = setOf(Important)) {
true shouldBeEqual true
}
"android NotImportant".config(tags = setOf(NotImportant)) {
true shouldBeEqual true
}
}
}
// src/commonTest
val Important = NamedTag("Important")
val NotImportant = NamedTag("NotImportant")
class MainTest : StringSpec() {
init {
println("Main kotest.tags->: ${System.getProperty("kotest.tags")}")
"Main Important".config(tags = setOf(Important)) {
true shouldBeEqual true
}
"Main NotImportant".config(tags = setOf(NotImportant)) {
true shouldBeEqual true
}
}
}
I tried also different Spec styles and different declaration of tag(class scope) but with no luck.
Run out of ideas so opening this issue.
Thanks a look for looking into it.
EDIT: It seems to work fine with 5.9.1 , however we are unable the run the iOS tests as we are using kotlin 2.+
Martin
Same here using 6.0.1...
Iām confident my Gradle configuration is correct. To inject kotest.tags I configured the test task as stated in documentation:
systemProperties = System.getProperties().asIterable().associate { it.key.toString() to it.value
Printing systemProperties confirms the property is configured correctly.
If we're using annotations, RequiresTag will always skip the test without a care, whereas Tags runs everything every time.