Hello everyone, I'd like to make one of my `Descri...
# kotest
x
Hello everyone, I'd like to make one of my
DescribeSpec
test
enabledIf
. This documentation page only mentions this with
FreeSpec
styled tests. I can't find what the syntax would be with a
describe
or
it
method.
Copy code
"should do something".config(enabledIf = { … }) {
  // test here
}
Looking at the source code, it feels like it's not possible:
Copy code
fun describe(name: String, test: suspend DescribeSpecContainerScope.() -> Unit) {
      addContainer(
         TestName("Describe: ", name, false),
         disabled = false,
         null // <-- this should be where the enabled is passed 
      ) { DescribeSpecContainerScope(this).test() }
   }
d
Is there really any difference between that enabledIf and just surrounding the piece with an
if(...) {...}
block 🤔?
x
Well, in the result not really, but it makes the test class less readable
d
It looks like this is what you're looking for: https://kotest.io/docs/framework/testcaseconfig.html
At least it seems implemented for
should(...).config(...) { }
and
test(...)..
I don't see why it wouldn't be for describe.
x
Oh great, thanks a lot @dave08, this is exactly what I was looking for 🙂
👍🏼 1