This site is inactive!

This site is no longer kept up to date. It has been superseded by the Roblox API Reference. Please update your bookmarks.

The TestService can be used for performing unit tests, as well as testing a place with various settings.

Members

Functions

Returns Function History
void Check ( bool condition, string description, Instance source = nil, int line = 0 )
void Checkpoint ( string text, Instance source = nil, int line = 0 )
void DoCommand ( string name ) (+0.57, −0.214)
void Done ( )
void Error ( string description, Instance source = nil, int line = 0 ) (+0.52)
void Fail ( string description, Instance source = nil, int line = 0 ) (+0.52)
Array GetCommandNames ( ) (+0.57, −0.214)
bool IsCommandChecked ( string name ) (+0.57, −0.214)
bool IsCommandEnabled ( string name ) (+0.57, −0.214)
void Message ( string text, Instance source = nil, int line = 0 )
void Require ( bool condition, string description, Instance source = nil, int line = 0 )
void Warn ( bool condition, string description, Instance source = nil, int line = 0 )

YieldFunctions

Returns YieldFunction History
void Run ( ) (+0.52)
  • 1 yieldfunction inherited from Instance

Events

Event History
ServerCollectConditionalResult ( bool condition, string text, Instance script, int line ) (+0.95)
ServerCollectResult ( string text, Instance script, int line ) (+0.95)

Detailed Description

Each method used for testing may emit a message to the output. This message begins with "TestService", indicating that it was emitted by a TestService method. A message may be an error (in red), a warning (in yellow), or a regular message (in blue).

Each test method also allows a source and a line to be optionally supplied as arguments. If they are given, then they are displayed in the message.

The source argument indicates a script object related to the message (such as the script where an error occurred). The script's Name is displayed before the main description or text of the message. Note that source may be any instance, not just a script.

line indicates an exact line in the script related to the message. If source is given, then the line is displayed after the source name. If not, then the line is not displayed.

Example messages:

Without source:

TestService: message

With source (SourceName) and line (123):

TestService.SourceName(123): message

Property Descriptions

bool TestService.AutoRuns

Version History:(+0.52)

string TestService.Description

int TestService.ErrorCount

Version History:(+0.52)

Tags: readonly

Indicates the number of errors and fatal errors that have occurred during a test.

bool TestService.ExecuteWithStudioRun

Version History:(+0.337)

bool TestService.Is30FpsThrottleEnabled

bool TestService.IsPhysicsEnvironmentalThrottled

bool TestService.IsSleepAllowed

int TestService.NumberOfPlayers

Version History:(+0.95)

double TestService.SimulateSecondsLag

Version History:(+0.178)

int TestService.TestCount

Version History:(+0.52)

Tags: readonly

Indicates the number of assertions that have been made during a test.

double TestService.Timeout

The amount of time, in seconds, in which a test must be completed.

int TestService.WarnCount

Version History:(+0.52)

Tags: readonly

Indicates the number of warnings that have occurred during a test.

Function Descriptions

voidTestService.Check ( bool condition, string description, Instance source = nil, int line = 0 )

Tests condition. If the condition is false, description is displayed as an error message in the output, and the ErrorCount property is incremented.

Calling this method increments the TestCount property.

voidTestService.Checkpoint ( string text, Instance source = nil, int line = 0 )

Displays text as a checkpoint message in the output.

voidTestService.DoCommand ( string name )

Version History:(+0.57, −0.214)

Tags: LocalUserSecurity

voidTestService.Done ( )

When performing a test with Run, the test can be completed by calling this method.

voidTestService.Error ( string description, Instance source = nil, int line = 0 )

Version History:(+0.52)

Unconditionally displays description as an error message in the output, and increments the ErrorCount property.

Calling this method increments the TestCount property.

voidTestService.Fail ( string description, Instance source = nil, int line = 0 )

Version History:(+0.52)

Unconditionally displays description as a fatal error message in the output, and increments the ErrorCount property.

Calling this method increments the TestCount property.

ArrayTestService.GetCommandNames ( )

Version History:(+0.57, −0.214)

Tags: LocalUserSecurity

boolTestService.IsCommandChecked ( string name )

Version History:(+0.57, −0.214)

Tags: LocalUserSecurity

boolTestService.IsCommandEnabled ( string name )

Version History:(+0.57, −0.214)

Tags: LocalUserSecurity

voidTestService.Message ( string text, Instance source = nil, int line = 0 )

Displays text as a regular message in the output.

voidTestService.Require ( bool condition, string description, Instance source = nil, int line = 0 )

Tests condition. If the condition is false, description is displayed as a fatal error message in the output, and the ErrorCount property is incremented.

Calling this method increments the TestCount property.

voidTestService.Warn ( bool condition, string description, Instance source = nil, int line = 0 )

Tests condition. If the condition is false, description is displayed as a warning message in the output, and the WarnCount property is incremented.

Calling this method increments the TestCount property.

YieldFunction Descriptions

voidTestService.Run ( )

Version History:(+0.52)

Tags: PluginSecurity

Used to begin a test. When called, all counters are reset, and the current thread is yielded until Done is called, or Timeout is reached.

If the test is completed, a regular message displays the number of tests, warnings, and errors that occurred during the test. If no assertions were made (i.e. if test count is 0), then a message indicating such will be displayed instead.

If Done is not called within the time limit, then an error message indicating such will be displayed.

Event Descriptions

TestService.ServerCollectConditionalResult ( bool condition, string text, Instance script, int line )

Version History:(+0.95)

TestService.ServerCollectResult ( string text, Instance script, int line )

Version History:(+0.95)

Inherits: