(info) This AI is still in early stages of development.

Test API - Dev Notes

Developer notes for this API...

 

Test Modes

Properties of mode objects – optional properties should not be specified if not applicable.

PropertyTypeMandatoryNotes
nameString(tick)

The mode name, in uppercase.

Note: Internally there is also a special "TIMEOUT" mode.

afterString(tick)

Test end event to call at the end of a unit test.

Possible values:

  • "DONE" – for synchronous tests
  • "WAIT" – for asynchronous tests
  • "TIMEOUT" – when an asynchronous test times out
appendToString(error)

If test appends an existing test, this is the name of the test that results will be appended to.

Default: Do not append results to another test.

expectNumber(error)

Number of results that must be logged before test is allowed to pass

Default: Do not prevent test from passing due to number of results

Note: Ignored if appendTo property is defined

ttlNumber(error)

If after == "WAIT" and the test has not passed or failed, this is the amount of of time (in game milliseconds) the test remains active for until timing out.

Default:

  • If after == "WAIT": 1000 (1 game second)
  • If after == "DONE": Force fail/success as soon as test finishes (ignore ttl)

Test States

Public constants but really aimed at internal use...

StateValueNotes
Test.UNIT_PENDINGundefinedIndicates the test has not yet started
Test.UNIT_RUNNINGnullIndicates the test is running (or waiting for more results in case of asynch mode)
Test.UNIT_SUCCESStrueIndicates test has completed successfully
Test.UNIT_FAILEDfalseIndicates test has failed
Test.UNIT_TIMEOUT0Indicates test has timed-out

Test End Events

Each unit test ends with one of the following events (either implicitly or due to a signal, etc).

EventNotesEffect on test state
"ERROR"

An error was thrown while running the test

Test.UNIT_FAILED
"ABORT"

An ABORT( ) signal was sent while running the test

Test.UNIT_FAILED
"REQUIRE"

A REQUIRE( ) signal was sent while running the test

Test.UNIT_FAILED
"DONE"

A synchronous test has finished

Test.UNIT_SUCCESS / Test.UNIT_FAILED
"FINISH"A FINISH( ) signal was sent while running the testTest.UNIT_SUCCESS / Test.UNIT_FAILED
"TIMEOUT"An asynchronous test has timed-out

Test.UNIT_TIMEOUT internally

After end event, will become either:

Test.UNIT_SUCCESS / Test.UNIT_FAILED

"WAIT"An asynchronous test has finished – check if it's passed, failed or still running

If passed or failed, redirect to "DONE"

Otherwise: Test.UNIT_RUNNING

Everything on this page relates to the internal code of the API and is thus liable to change without warning.
Contents

Jump to:

Roadmap

Future plans:

  • Implement set-up and tear-down features for unit tests Aubergine
  • Make test modes moddable to some degree Aubergine
  • Rename mode.toTest to mode.appendTo Aubergine
  • Add modes for min/max number of results before test can pass Aubergine