# cp.spec.Run.This

A token passed to test functions to allow them to indicate if a test run will complete asynchronously.


# API Overview

Constants - Useful values which cannot be changed

  • state

Functions - API calls offered directly by the extension

  • defaultTimeout

Constructors - API calls which return an object, typically one that offers API methods

  • This

Methods - API calls which can only be made on an object returned by a constructor

  • abort
  • cleanup
  • done
  • expectAbort
  • expectFail
  • fail
  • isActive
  • isDone
  • isWaiting
  • log
  • prepare
  • run
  • toObserver
  • wait

# API Documentation

# Constants

# state

Signature cp.spec.Run.This.state
Type Constant
Description A collection of states that a Run.This can be in.
Notes
  • States include:
  • running - The Run is currently running and will terminate at the end of the function (synchrnonous).
  • waiting - The Run is waiting, and will terminate when done() is called. (asynchronous).
  • done - The Run is done.
Source src/extensions/cp/spec/Run.lua line 31

# Functions

# defaultTimeout

Signature cp.spec.Run.This.defaultTimeout([timeout]) -> number
Type Function
Description Gets and/or sets the default timeout for asynchronous tests. Defaults to 60 seconds.
Parameters
  • timeout - (optional) the new timeout, in seconds.
Returns
  • The current default timeout, in seconds.
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 48

# Constructors

# This

Signature cp.spec.Run.This(run, actionFn, index) -> cp.spec.Run.This
Type Constructor
Description Creates a new Run.This instance for a Run.
Parameters
  • run - The Run.
  • actionFn - The action function to execute.
  • index - The index of the action in the current phase.
Returns
  • The new Run.This.
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 64

# Methods

# abort

Signature cp.spec.Run.This:abort([message]) -> boolean
Type Method
Description Indicates the stage has aborted.
Parameters
  • message - The optional message to output.
Returns
  • A boolean
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 403

# cleanup

Signature cp.spec.Run.This:cleanup()
Type Method
Description Cleans up This after a step.
Parameters
  • None
Returns
  • None
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 489

# done

Signature cp.spec.Run.This:done()
Type Method
Description Indicates that the test is completed.
Parameters
  • None
Returns
  • None
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 346

# expectAbort

Signature cp.spec.Run.This:expectAbort([messagePattern]) -> Run.This
Type Method
Description Indicates that this spec is expecting an abort/error to occur.
Parameters
  • messagePattern - The pattern to check the fail message against. If not provided, any message will match.
Returns
  • The same Run.This instance.
Notes
  • When this is expected, it doesn't log the problem as a 'fail'. In fact, if the it doesn't occur at some point during the run, it will raise a failure at the end of the run.
  • The messagePattern can be used to ensure it's the fail you expect.
  • This should be called before the actual abort/error would occur.
Examples None
Source src/extensions/cp/spec/Run.lua line 207

# expectFail

Signature cp.spec.Run.This:expectFail([messagePattern]) -> Run.This
Type Method
Description Indicates that this spec is expecting an assert/fail to occur.
Parameters
  • messagePattern - The pattern to check the fail message against. If not provided, any message will match.
Returns
  • The same Run.This instance.
Notes
  • When this is expected, it doesn't log the problem as a 'fail'. In fact, if the fail doesn't occur, it will raise a failure at the end of the run.
  • The messagePattern can be used to ensure it's the fail you expect.
  • This should be called before the actual assert/fail would occur.
Examples None
Source src/extensions/cp/spec/Run.lua line 120

# fail

Signature cp.spec.Run.This:fail([message]) -> boolean
Type Method
Description Indicates the run has failed.
Parameters
  • message - The optional message to output.
Returns
  • A boolean
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 427

# isActive

Signature cp.spec.Run.This:isActive() -> boolean
Type Method
Description Checks if the this is in an active state - either running or waiting.
Parameters
  • None
Returns
  • true if isActive.
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 295

# isDone

Signature cp.spec.Run.This:isDone() -> boolean
Type Method
Description Returns true if this is done.
Parameters
  • None
Returns
  • A boolean
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 390

# isWaiting

Signature cp.spec.Run.This:isWaiting() -> boolean
Type Method
Description Checks if the Run is waiting for this execution to complete via the done method.
Parameters
  • None
Returns
  • true if the waiting.
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 333

# log

Signature cp.spec.Run.This:log(message[, ...])
Type Method
Description When the current Run is in debug mode, output the message to the console.
Parameters
  • message - the text message to output.
  • ... - optional parameters, to be injected into the message, ala string.format.
Returns
  • None
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 713

# prepare

Signature cp.spec.Run.This:prepare()
Type Method
Description Prepares this to run.
Parameters
  • None
Returns
  • None
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 477

# run

Signature cp.spec.Run.This:run() -> cp.spec.Run
Type Method
Description Returns the current Run
Parameters
  • None
Returns
  • Returns the current Run
Notes None
Examples None
Source src/extensions/cp/spec/Run.lua line 86

# toObserver

Signature cp.spec.Run.This:toObserver([onNext[, onError[, onCompleted]]) -> cp.rx.Observer
Type Method
Description Creates an Observer.
Parameters
  • onNext - The next handler.
  • onError - The error handler.
  • onCompleted - The completed handler.
Returns
  • cp.rx.Observer
Notes
  • If the onNext/onError/onCompleted functions are
  • not provided, then it will provide defaults. onNext will be logged, onError will throw an error,
  • and onCompleted will trigger done.
Examples None
Source src/extensions/cp/spec/Run.lua line 272

# wait

Signature cp.spec.Run.This:wait([timeout]) -> none
Type Method
Description Indicates that the test is continuing asynchronously, and will be completed by calling done.
Parameters
  • timeout - (optional) The number of seconds to wait before timing out.
Returns
  • None
Notes
  • If not provided, Run.This.defaultTimeout() is used.
Examples None
Source src/extensions/cp/spec/Run.lua line 308