This AI is still in early stages of development.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

After testing is finished, output results...

 

Overview

This feature is still under development...

The Test API provides some default results output methods, however you can add your own if desired.

Tip: You can trigger output using Test Events.

Outputting results

Results are output by invoking Test.sendResultsTo() with the appropriate parameter, for example:

Test.sendResultsTo("console");

A config script is available that adds the following output methods to the Test API:

MethodOutputs toNotesAPI Version
"summary"console()

Outputs a very brief one-line summary to the console.

Note: You'll need to switch to the player via  Debug Menu to see their console. 

1.2
"console"console()

Outputs detailed summary, a few lines at a time, to the console.

Note: You'll need to switch to the player via Debug Menu to see their console.

1.2
"host"chat()

Same as "console" but sends output via chat messages to player 0.

If chat() is not available, reverts to using "console".

1.2
"log"log()

Same as "console" but sends output to the log file associated with the player.

If log() is not available, reverts to using "console".

Not yet implemented
"html"log()

Outputs results in posh HTML format to the log file associated with the player.

If log() is not available, reverts to using "console".

Not yet implemented

If you've installed Util API, the config script will automatically load as soon as the Test API is loaded. If you've not got Util API installed, you'll have to manually include "path/to/Config/Test.js" after including "path/to/APIs/Test.js".

Creating custom output methods

To create a custom output method, or overwrite one of the existing methods, you'll need to provide an object that defines the method name and the function that outputs the results:

Test.output = {
	name: "example",
	generator: function(results, typeOf) {
		// work your magic here
	}
};

You can add any number of output methods this way – all of the bundled methods are defined this way.

The results parameter is an array of objects (see below) and the typeOf parameter is a reference to typeOf() (or the Test API equivalent if you've not installed Util API).

The structure of the results array is as follows:

  • results[<idx>] – numeric references link to module objects in the order they were defined
    • .modulePath – the module's path
    • .state – did the module pass or fail? (true or false)
    • .numPassed – how many tests passed in the module?
    • .numFailed – how many tests failed in the module?
    • .url – the URL associated with the module (if applicable)
    • .tests[<idx>] – numeric references link to test objects associated with the module
      • .testName – the name of the test
      • .testMode – the object defining the test mode
        • .name – the mode name ("ANY", "EXPECT" or "ASYNCH")
        • .expect – the number of expected results (if applicable)
      • .state – did the unit test pass or fail? (true or false)
      • .results[<idx>] – numeric references link to results associated with the test
        • .passed – did the assertion pass or fail? (true or false, or null if a comment)
        • .expected – the expected value (if applicable)
        • .actual – the actual value (if applicable)
        • .name – the name of the Test AssertionTest Signal, etc., that generated the result
        • .message – the message associated with the result
        • .isComment – is the result a comment? (true or false)
Availability DEV

Requires:

Contents

Jump to:

Test API

Topics:

  • Test()Define a unit test and it's configuration...
  • Test ModulesA test module groups one or more unit tests and provides additional lifecycle settings for those tests...
  • Test ModesDefines the mode in which a unit test is run...
    • Test.ANY( )The most basic unit test mode...
    • Test.EXPECT( )Causes the test to fail if it does not generate the specified number of results...
    • Test.ASYNCH( )Causes a test to keep running until it either passes, fails or times-out...
    • Test.APPEND( )Appends results to a specific asynchronous test session...
  • Unit TestsThe unit test function, responsible for performing one or more Test Assertions...
  • Test AssertionsAssertions are used to perform various tests and annotations within a unit test...
    • comment( )Adds a comment to the test results...
    • ok( )A simple state checking assertion...
    • hasNative( )Assert presence of a native property on the global object...
    • hasFunction( )Check if a context has a function property, optionally with specified number of formal parameters...
    • equal( )A basic equality checking assertion...
    • notEqual( )A basic inequality checking assertion...
    • strictEqual( )A strict equality checking assertion...
    • notStrictEqual( )A strict inequality checking assertion...
    • deepEqual( )A deep equality checking assertion...
    • notDeepEqual( )A deep inequality checking assertion...
    • similarTo( )A deep similarity checking assertion...
    • notSimilarTo( )A deep dissimilarity spotting assertion...
  • Test SignalsSignals are used to prematurely terminate Unit Tests...
    • REQUIRE( )Check whether a test or group of tests have passed. If the requirement fails, a RequireSignal will be sent which terminates the current test and marks it as failed.
    • ABORT( )Aborts the current test, marking it as failed in the process...
    • FINISH( )Terminates the test as if it had finished normally...
  • Test EventsEvents defined by Test API...
  • Test ResultsAfter testing is finished, output results...
  • Test API - Dev NotesDeveloper notes for this API...

 

  • No labels