1

What is the easiest way to run the same test and the same suite or class n times in a row using kotest framework?

1 Answers1

2

I'm not sure if you can run the same test class n times, but you can configure all tests in the class to run n times by setting the default config for the class like so:

class RepeatAllTests : FunSpec() {
  override fun defaultConfig() = TestCaseConfig(invocations = 5)
  init {
    test("repeat us") { 0 shouldBe 0 }
  }
}

Or you can mark a specific test to be repeated like so:

class RepeatATest : FunSpec() {
  init {
    test("repeat me").config(invocations = 5) { 0 shouldBe 1 }
  }
}

Also see the docs regarding invocations here: http://kotest.io/docs/framework/testcaseconfig.html

jschneidereit
  • 323
  • 1
  • 6