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",
method: 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 method function has two parameters. The results parameter is an array of objects (see below for structure) 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
similarTo( ) — A deep similarity checking assertion...
notSimilarTo( ) — A deep dissimilarity spotting assertion...
Test Signals — Signals 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...