#cp.spec.Run

An individual run of a test Definition or Specification.


#Submodules


#API Overview

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

Fields - Variables which can only be accessed from an object returned by a constructor

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


#API Documentation

#Constructors

Signaturecp.spec.Run(name, source) -> cp.spec.Run
TypeConstructor
DescriptionCreates a new test run.
Parameters
  • name - The name of the run.
  • source - The object (typically a Definition) that initiated the run.
Returns
  • cp.spec.Run
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 573

#Fields

Signaturecp.spec.Run.phase <cp.spec.Run.phase>
TypeField
DescriptionThe current phase of the run.
NotesNone
Sourcesrc/extensions/cp/spec/Run.lua line 612

Signaturecp.spec.Run.report <cp.spec.Report>
TypeField
DescriptionThe reports of the run.
NotesNone
Sourcesrc/extensions/cp/spec/Run.lua line 585

Signaturecp.spec.Run.result <cp.spec.Run.result>
TypeField
DescriptionThe current result. Defaults to Run.result.passing.
NotesNone
Sourcesrc/extensions/cp/spec/Run.lua line 617

Signaturecp.spec.Run.shared <table>
TypeField
DescriptionThe set of data shared by all phases of the Run. Data from parent Runs will also be available.
NotesNone
Sourcesrc/extensions/cp/spec/Run.lua line 600

Signaturecp.spec.Run.source
TypeField
DescriptionThe object that initiated the run. Typically a Definition.
NotesNone
Sourcesrc/extensions/cp/spec/Run.lua line 593

#Methods

Signaturecp.spec.Run:debug() -> cp.spec.Run
TypeMethod
DescriptionEnables debugging on this Run. Any calls to [#log] will be output to the console.
Parameters
  • None
Returns
  • The same Run instance.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 670

Signaturecp.spec.Run:expectAbort([messagePattern]) -> Run
TypeMethod
DescriptionIndicates 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.
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.
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 186

Signaturecp.spec.Run:expectFail([messagePattern]) -> Run
TypeMethod
DescriptionIndicates 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.
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.
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 99

Signaturecp.spec.Run:isDebugging() -> boolean
TypeMethod
DescriptionChecks if debug has been enabled on this or any parent Run.
Parameters
  • None
Returns
  • A boolean
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 684

Signaturecp.spec.Run:isExpectingAbort() -> boolean, string or nil
TypeMethod
DescriptionChecks if the run is expecting a abort/error to occur. If so, it will return the expected message pattern as the second value, if specified.
Parameters
  • None
Returns
  • boolean - true, if a fail is expected.
  • string - the message pattern, if specified.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 226

Signaturecp.spec.Run:isExpectingFail() -> boolean, string or nil
TypeMethod
DescriptionChecks if the run is expecting a fail to occur. If so, it will return the expected message pattern, if specified.
Parameters
  • None
Returns
  • boolean - true, if a fail is expected.
  • string - the message pattern, if specified.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 139

Signaturecp.spec.Run:log(message[, ...])
TypeMethod
DescriptionWhen 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
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 697

Signaturecp.spec.Run:onBefore(actionFn) -> self
TypeMethod
DescriptionAdds 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.
Returns
  • self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 885

Signaturecp.spec.Run:onBfter(actionFn) -> self
TypeMethod
DescriptionAdds 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.
Returns
  • self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 911

Signaturecp.spec.Run:onRunning(actionFn) -> self
TypeMethod
DescriptionAdds a callback function to run during the test.
Parameters
  • runningFn - The function to run, passed Run.This as the first parameter.
Returns
  • self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 898

Signaturecp.spec.Run:parent([parent]) -> cp.spec.Run
TypeMethod
DescriptionGets 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.
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 838

Signaturecp.spec.Run:verbose([isVerbose]) -> boolean | self
TypeMethod
DescriptionEither sets the verbose value and returns itself for further chaining, or returns the current verbose status.
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.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Run.lua line 862