Skip to content

Latest commit

 

History

History
48 lines (40 loc) · 1.16 KB

File metadata and controls

48 lines (40 loc) · 1.16 KB
id title slug sidebar_label
fail_fast
Fail Fast
fail-fast.html
Fail Fast

Kotest can eagerly fail a list of tests if one of those tests fails. This is called fail fast.

Fail fast can take affect at the spec level, or at a parent test level.

In the following example, we enable failfast for a parent test, and the first failure inside that context, will cause the rest to be skipped.

class FailFastTests() : FunSpec() {
   init {
      context("context with fail fast enabled").config(failfast = true) {
         test("a") {} // pass
         test("b") { error("boom") } // fail
         test("c") {} // skipped
         context("d") {  // skipped
            test("e") {} // skipped
         }
      }
   }
}

This can be enabled for all scopes in a Spec by setting failfast at the spec level.

class FailFastTests() : FunSpec() {
   init {

      failfast = true

      context("context with fail fast enabled at the spec level") {
         test("a") {} // pass
         test("b") { error("boom") } // fail
         test("c") {} // skipped
         context("d") {  // skipped
            test("e") {} // skipped
         }
      }
   }
}