Hi everyone! I'm running Kotest 5.4.2, and I'm try...
# kotest
v
Hi everyone! I'm running Kotest 5.4.2, and I'm trying to disable some tests by using
enableOrReasonIf
. I am following the examples in the documentation so I have the following:
Copy code
val disabledForReasonX: (TestCase) -> Enabled = { Enabled.disabled("...") }

test("...").config(enabledOrReasonIf = disabledForReasonX) { ... }
It seems like
enabledOrReasonIf
is only available using StringSpec. How can we do something similar in FunSpec?
s
It should be available on all specs
Here is a test from the Kotest test suite:
Copy code
private class EnabledOrReasonIfSpec : FunSpec() {
   init {
      test("a").config(enabledOrReasonIf = { Enabled.disabled("wobble") }) {
         throw RuntimeException()
      }
   }
}
Can you paste up the code that isn't working ?
v
Hi Sam! I think I've narrowed down the issue.
enabledOrReasonIf
is not available in nested tests. See my example below:
Copy code
class ExampleTest : FunSpec({
    val disabledDueToBugXXX: (TestCase) -> Enabled = { Enabled.disabled("Disabled until BUG-XXX is fixed.") }
    
    test("example").config(enabledOrReasonIf = disabledDueToBugXXX) {
        fail("Not implemented yet.")
    }
    
    context("blah") {
        test("example 2").config(enabledOrReasonIf()) { // does not compile.
            fail("Not implemented yet.")
        }
    }
})
s
checking
ok I've pushed a fix. That will be in either 5.4.3 or 5.5.0
v
Thank you!