kotest-core / io.kotest.core.config / AbstractProjectConfig

AbstractProjectConfig

abstract class AbstractProjectConfig

Project-wide configuration. Extensions returned by an instance of this class will be applied to all Spec and TestCases.

Create an object that is derived from this class, name the object ProjectConfig and place it in your classpath in a package called io.kotest.provided.

Kotest will detect its presence and use it when executing tests.

Note: This is a breaking change from versions 2.0 and before, in which Kotest would scan the classpath for instances of this class. It no longer does that, in favour of the predefined package name + classname.

Constructors

<init>

Project-wide configuration. Extensions returned by an instance of this class will be applied to all Spec and TestCases.

AbstractProjectConfig()

Properties

assertionMode

Override this value to set a global AssertionMode. If a Spec sets an assertion mode, then the spec will override.

open val assertionMode: AssertionMode?

autoScanEnabled

Override this value and set it to false if you want to disable autoscanning of extensions and listeners.

open val autoScanEnabled: Boolean?

autoScanIgnoredClasses

Override this value with a list of classes for which @autoscan is disabled.

open val autoScanIgnoredClasses: List<KClass<*>>

defaultTestCaseConfig

Any TestCaseConfig set here is used as the default for tests, unless overriden in a spec, or in a test itself. In other words the order is test -> spec -> project config default -> kotest default

open val defaultTestCaseConfig: TestCaseConfig?

failOnIgnoredTests

Override this value and set it to true if you want the build to be marked as failed if there was one or more tests that were disabled/ignored.

open val failOnIgnoredTests: Boolean

globalAssertSoftly

Override this value and set it to true if you want all tests to behave as if they were operating in an assertSoftly block.

open val globalAssertSoftly: Boolean?

isolationMode

open val isolationMode: IsolationMode?

parallelism

open val parallelism: Int

specExecutionOrder

Note: This has no effect on non-JVM targets.

open val specExecutionOrder: SpecExecutionOrder?

testCaseOrder

open val testCaseOrder: TestCaseOrder?

timeout

A global timeout that is applied to all tests if not null. Tests which define their own timeout will override this. The value here is in millis

open val timeout: Duration?

writeSpecFailureFile

open val writeSpecFailureFile: Boolean?

Functions

afterAll

Executed after the last test of the project, but before the ProjectListener.afterProject methods.

open fun afterAll(): Unit

beforeAll

Executed before the first test of the project, but after the ProjectListener.beforeProject methods.

open fun beforeAll(): Unit

extensions

List of project wide Extension instances.

open fun extensions(): List<Extension>

filters

List of project wide Filter instances.

open fun filters(): List<Filter>

isolationMode

The IsolationMode set here will be applied if the isolation mode in a spec is null.

open fun isolationMode(): IsolationMode?

listeners

List of project wide Listener instances.

open fun listeners(): List<Listener>

parallelism

Override this function and return a number greater than 1 if you wish to enable parallel execution of tests. The number returned is the number of concurrently executing specs.

open fun parallelism(): Int

projectListeners

List of project wide ProjectListener instances.

open fun projectListeners(): List<ProjectListener>

specExecutionOrder

Override this function and return an instance of SpecExecutionOrder which will be used to sort specs before execution.

open fun specExecutionOrder(): SpecExecutionOrder?

testCaseOrder

Sets the order of top level tests in a spec. The value set here will be used unless overriden in a Spec. The value in a Spec is always taken in preference to the value here. Nested tests will always be executed in discovery order.

open fun testCaseOrder(): TestCaseOrder?

writeSpecFailureFile

When set to true, failed specs are written to a file called spec_failures. This file is used on subsequent test runs to run the failed specs first.

open fun writeSpecFailureFile(): Boolean