Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Latest commit

 

History

History
167 lines (141 loc) · 14 KB

cp.spec.Run.md

File metadata and controls

167 lines (141 loc) · 14 KB

docs » cp.spec.Run


An individual run of a test Definition or Specification.

Submodules

API Overview

API Documentation

Constructors

Signature cp.spec.Run(name) -> cp.spec.Run
Type Constructor
Description Creates a new test run.
Parameters
  • name - The name of the run.
  • source - The object (typically a Definition) that initiated the run.

Fields

Signature cp.spec.Run.phase <cp.spec.Run.phase>
Type Field
Description The current phase of the run.
Signature cp.spec.Run.report <cp.spec.Report>
Type Field
Description The reports of the run.
Signature cp.spec.Run.result <cp.spec.Run.result>
Type Field
Description The current result. Defaults to Run.result.passing.
Signature cp.spec.Run.shared <table>
Type Field
Description The set of data shared by all phases of the Run. Data from parent Runs will also be available.
Signature cp.spec.Run.source
Type Field
Description The object that initiated the run. Typically a Definition.

Methods

Signature cp.spec.Run:debug() -> cp.spec.Run
Type Method
Description Enables debugging on this Run. Any calls to [#log] will be output to the console.
Parameters
  • None
Returns
  • The same Run instance.
Signature cp.spec.Run:expectAbort([messagePattern]) -> Run
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 instance.
Signature cp.spec.Run:expectFail([messagePattern]) -> Run
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 instance.
Signature cp.spec.Run:isDebugging() -> boolean
Type Method
Description Checks if debug has been enabled on this or any parent Run.
Signature cp.spec.Run:isExpectingAbort() -> boolean, string or nil
Type Method
Description Checks if the run is expecting a abort/error to occur.
Parameters
  • None
Returns
  • boolean - true, if a fail is expected.
  • string - the message pattern, if specified.
Signature cp.spec.Run:isExpectingFail() -> boolean, string or nil
Type Method
Description Checks if the run is expecting a fail to occur.
Parameters
  • None
Returns
  • boolean - true, if a fail is expected.
  • string - the message pattern, if specified.
Signature cp.spec.Run: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.
Signature cp.spec.Run:onBefore(actionFn) -> self
Type Method
Description Adds a callback function to run prior to executing the actual test.
Parameters
  • actionFn - The function to run, passed this Run.This as the first parameter.
Signature cp.spec.Run:onBfter(actionFn) -> self
Type Method
Description Adds a callback function to run after to executing the actual test, pass or fail.
Parameters
  • actionFn - The function to run, passed this Run as the first parameter.
Signature cp.spec.Run:onRunning(actionFn) -> self
Type Method
Description Adds a callback function to run during the test.
Parameters
  • runningFn - The function to run, passed Run.This as the first parameter.
Signature cp.spec.Run:parent([parent]) -> cp.spec.Run
Type Method
Description Gets and/or sets the parent Run for this run.
Parameters
  • parent - (optional) If set, will set the parent Run.
Returns
  • The current parent Run.
Notes
  • If a parent is provided and there is already another Run set as a parent, an error is thrown.

| Signature | cp.spec.Run:verbose([isVerbose]) -> boolean | self | | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Either sets the verbose value and returns itself for further chaining, or returns | | Parameters |

  • isVerbose - (optional) if true or false will update the verbose status and return this Run.
| | Returns |
  • The current verbose status, or this Run if isVerbose is provided.
|