class to be used for executing some Test Function after checking with the PolicyManager to confirm that the testFunction should be executed based on referenced Test ID(s) or lack thereof

ex:

await aftTest('[C1234] example usage for AftTest', async (v: AftTest) => {
await v.reporter.info('doing some testing...');
const feature = new FeatureObj();
await v.verify(() => feature.returnExpectedValueAsync(), containing('expected value'));
}); // if PolicyManager.shouldRun('C1234') returns `false` the `testFunction` is not run

Hierarchy

  • AftTest

Constructors

Properties

_endTime: number
_options: AftTestOptions
_resultsCache: CacheMap<string, TestResult[]>
_startTime: number
_testFunction: AftTestFunction
description: string

Accessors

  • get elapsed(): number
  • returns the amount of time, in milliseconds, elapsed since the AftTest was started either by calling the run function or using aftTest(description, testFunction, options) helper function until it ended or now if not yet done

    NOTE

    this includes the time taken to query any PolicyPlugin instances

    Returns number

  • get results(): TestResult[]
  • returns an array of TestResult objects for each result already submitted via a call to verify, pass, fail or pending or the completion of the testFunction execution within the run function

    NOTE:

    one result is submitted for each associated Test ID or just one overall result if no Test IDs are associated with this instance if withFileSystemCache is enabled this includes searching the filesystem cache for any logged test results for the AftTest.description and returning the results as an array of TestResult objects with each object corresponding to a Test ID referenced in the test name

    Returns TestResult[]

    an array of TestResult objects where each entry corresponds to a referenced Test ID parsed from the AftTest.description

  • get testIds(): string[]
  • an array of string values representing the associated test IDs for this AftTest. for each test ID a unique result can and will be reported during or on the completion of running the testFunction

    ex: ["C1234", "C2345"]

    Returns string[]

Methods

  • creates TestResult objects for each testId and sends these to the ReportingManager.submitResult function

    Parameters

    • status: TestStatus
    • Optional message: string
    • Rest ...testIds: string[]

    Returns Promise<void>

  • executes any 'fail' event actions after submitting a 'failed' result for each associated test ID and then throws a AftTestFailError to halt execution of the testFunction (if running)

    Parameters

    • Optional message: string

      an optional message to describe why the test is being marked as 'failed'

    Returns Promise<void>

    Default

    "unknown error occurred"
    
  • executes any 'pass' event actions after submitting a 'passed' result for each associated test ID and then throws a AftTestPassError to halt execution of the testFunction (if running)

    Returns Promise<void>

  • executes any 'skipped' event actions after submitting a 'skipped' result for each associated test ID and then throws a AftTestPendingError to halt execution of the testFunction (if running)

    Parameters

    • Optional message: string

      an optional message to describe why the test is being skipped

    Returns Promise<void>

    Default

    "test skipped"
    
  • this function handles event actions and checking the PolicyManager to determine if the supplied testFunction should be run. immediately prior to executing the testFunction the _started function is called followed by execution of the testFunction and then calling _done

    NOTE

    if using the aftTest helper function then run is automatically called, otherwise it must manually be called to run the testFunction

    Returns Promise<AftTest>

    this AftTest instance

  • performs a comparison of an actual and expected result. by default any error will result in halting the execution of the AftTest and reporting a failure, but by setting the haltOnVerifyFailure option to false you can allow the test execution to continue and only report the failure at the completion of running the testFunction

    ex:

    // no message and continues on verify failure
    await aftTest('continue on failure', async (v: AftTest) => {
    await v.verify(true, false);
    // below will run because "haltOnVerifyFailure" is "false"
    // but overall status will be 'failed' because above
    // call fails
    await v.verify(true, true);
    }, {haltOnVerifyFailure: false});

    // message with test ID (failure)
    await aftTest('[C1234] error on failure', async (v: AftTest) => {
    // submits `TestResult` for test ID `C1234` with `status='failed'`
    // and `message="C1234 - expected 'false' to be 'true'"`
    await v.verify(true, false, '[C1234]');
    });

    // message with test ID (success)
    await aftTest('[C1234] successful test', async (v: AftTest) => {
    // submits `TestResult` for test ID `C1234` with `status='passed'`
    await v.verify(true, true, '[C1234]');
    });

    Parameters

    • actual: any

      the actual result from some action

    • expected: any

      the expected result from the action

    • Optional message: string

      an optional message to include before any error string when a failure occurs. this may also include any test ID(s) in the form "...[TestID]..." and if included will result in a call to pass or fail with the associated test ID(s)

    Returns Promise<ProcessingResult<boolean>>

    a ProcessingResult<boolean> where ProcessingResult.result === true equates to success and ProcessingResult.result !== true equates to failure.

    NOTE:

    if a message argument is passed to the verify call then it will be included in the message property of the returned ProcessingResult

Generated using TypeDoc