TestController

Entry point to discover and execute tests. It contains TestController.items which are used to populate the editor UI, and is associated with run profiles to allow for tests to be executed.

Online Documentation

Properties

Link copied to clipboard
abstract val id: String

The id of the controller passed in tests.createTestController. This must be globally unique.

Link copied to clipboard

A collection of "top-level" TestItem instances, which can in turn have their own children to form the "test tree."

Link copied to clipboard
abstract var label: String

Human-readable label for the test controller.

Link copied to clipboard
abstract var refreshHandler: (token: CancellationToken) -> PromiseLike<Void>??

If this method is present, a refresh button will be present in the UI, and this method will be invoked when it's clicked. When called, the extension should scan the workspace for any new, changed, or removed tests.

Link copied to clipboard
abstract var resolveHandler: (item: TestItem?) -> PromiseLike<Void>?

A function provided by the extension that the editor may call to request children of a test item, if the TestItem.canResolveChildren is true. When called, the item should discover children and call TestController.createTestItem as children are discovered.

Functions

Link copied to clipboard
abstract fun createRunProfile(    label: String,     kind: TestRunProfileKind,     runHandler: (request: TestRunRequest, token: CancellationToken) -> PromiseLike<Void>,     isDefault: Boolean = definedExternally,     tag: TestTag = definedExternally,     supportsContinuousRun: Boolean = definedExternally): TestRunProfile

Creates a profile used for running tests. Extensions must create at least one profile in order for tests to be run.

Link copied to clipboard
abstract fun createTestItem(id: String, label: String, uri: Uri = definedExternally): TestItem

Creates a new managed TestItem instance. It can be added into the TestItem.children of an existing item, or into the TestController.items.

Link copied to clipboard
abstract fun createTestRun(request: TestRunRequest, name: String = definedExternally, persist: Boolean = definedExternally): TestRun

Creates a TestRun. This should be called by the TestRunProfile when a request is made to execute tests, and may also be called if a test run is detected externally. Once created, tests that are included in the request will be moved into the queued state.

Link copied to clipboard
abstract override fun dispose()

Unregisters the test controller, disposing of its associated tests and unpersisted results.

Link copied to clipboard
abstract fun invalidateTestResults(items: JsAny = definedExternally)

Marks an item's results as being outdated. This is commonly called when code or configuration changes and previous results should no longer be considered relevant. The same logic used to mark results as outdated may be used to drive continuous test runs.