All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.kotlintest.extensions.SpecExtension.kt Maven / Gradle / Ivy

There is a newer version: 3.4.2
Show newest version
package io.kotlintest.extensions

import io.kotlintest.AbstractProjectConfig
import io.kotlintest.Description
import io.kotlintest.Spec
import io.kotlintest.TestCase

/**
 * Reusable spec extension to be registered project wide
 * using [AbstractProjectConfig.extensions] or on a
 * per-spec basis by overriding `extensions()` in a [Spec] class.
 */
interface SpecExtension : ProjectLevelExtension, SpecLevelExtension {

  /**
   * Intercepts execution of a [Spec].
   *
   * Implementations must invoke the process callback if they
   * wish this spec to be executed. If they want to skip
   * the tests in this spec they can elect not to invoke
   * the callback.
   *
   * Once the process function returns, the execution of this
   * [Spec] and all it's nested [TestCase]s are guaranteed
   * to have been completed.
   *
   * @param context contains the [Spec] instance under consideration and the [Description] identifer.
   * @param process callback function required to continue spec processing
   */
  fun intercept(context: SpecInterceptContext, process: () -> Unit) = process()
}

data class SpecInterceptContext(val description: Description, val spec: Spec)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy