TestConfig

open class TestConfig(source)

A test element's configuration, modifying the execution of tests and suites.

A test element can be configured via any number of chained TestConfigs.

When TestConfigs are combined into a chain,

  • a conflicting TestConfig which occurs later takes precedence over an earlier one,

  • non-conflicting coroutine context elements accumulate,

  • a series of aroundAll, aroundEach wrappers, or traversals nest from the outside to the inside in order of appearance.

Each TestConfig operates at the TestElement level where it is configured. However, child elements inherit some configuration effects as described in the respective TestConfig function.

Use an existing configuration or the empty TestConfig object as the starting point, then invoke the TestConfig functions to return chained configurations.

Example:

testConfig = TestConfig
.coroutineContext(UnconfinedTestDispatcher())
.invocation(TestInvocation.CONCURRENT)

Inheritors

Types

Link copied to clipboard

The initial (empty) test configuration.

Functions

Link copied to clipboard

Returns a test configuration which adds permits for all TestSuites of a TestElement hierarchy.

Link copied to clipboard

Returns a test configuration which wraps executionWrappingAction around a single test element.

Link copied to clipboard

Returns a test configuration which wraps executionWrappingAction around each element of a TestElement hierarchy.

Link copied to clipboard

Returns a test configuration which wraps executionWrappingAction around each Test of a TestElement hierarchy.

Link copied to clipboard
fun chainedWith(otherConfiguration: TestConfig): TestConfig

Returns a TestConfig which chains this configuration with otherConfiguration.

Link copied to clipboard

Returns a test configuration which wraps a coroutine context around the TestElement's execution.

Link copied to clipboard

Returns a test configuration which disables test execution for a TestElement hierarchy.

Link copied to clipboard

Returns a test configuration which adds a TestExecutionReport to a test element hierarchy.

Link copied to clipboard
fun TestConfig.failFast(maxFailureCount: Int): TestConfig

Returns a test configuration which establishes a "fail fast" strategy on a TestElement hierarchy.

Link copied to clipboard

Returns a test configuration which specifies an invocation mode for all TestSuites of a TestElement hierarchy.

Link copied to clipboard
fun TestConfig.mainDispatcher(dispatcher: CoroutineDispatcher? = null): TestConfig

Returns a test configuration which specifies a main dispatcher (Dispatchers.setMain) for a TestElement hierarchy.

Link copied to clipboard

Returns a test configuration which specifies a set of permits for all TestSuites of a TestElement hierarchy.

Link copied to clipboard

Returns a test configuration which removes permits for all TestSuites of a TestElement hierarchy.

Link copied to clipboard

Returns a test configuration which wraps a single-threaded dispatcher around a TestElement's execution.

Link copied to clipboard
fun TestConfig.testScope(isEnabled: Boolean, timeout: Duration = 60.seconds): TestConfig

Returns a test configuration which enables/disables a kotlinx.coroutines.test.TestScope for a TestElement hierarchy.

Link copied to clipboard

Returns a test configuration which applies a TestExecutionTraversal to each element of a TestElement hierarchy.