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.
Property | Type | History | |
---|---|---|---|
AutoRuns | bool | (+0.52) | |
Description | string | ||
ErrorCount | int | (+0.52) | |
ExecuteWithStudioRun | bool | (+0.337) | |
Is30FpsThrottleEnabled | bool | ||
IsPhysicsEnvironmentalThrottled | bool | ||
IsSleepAllowed | bool | ||
NumberOfPlayers | int | (+0.95) | |
SimulateSecondsLag | double | (+0.178) | |
TestCount | int | (+0.52) | |
Timeout | double | ||
WarnCount | int | (+0.52) |
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 ) |
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
Version History:(+0.52)
Tags: readonly
Indicates the number of errors and fatal errors that have occurred during a test.
Version History:(+0.52)
Tags: readonly
Indicates the number of assertions that have been made during a test.
The amount of time, in seconds, in which a test must be completed.
Version History:(+0.52)
Tags: readonly
Indicates the number of warnings that have occurred during a test.
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.
Displays text as a checkpoint message in the output.
When performing a test with Run, the test can be completed by calling this method.
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.
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.
Version History:(+0.57, −0.214)
Tags: LocalUserSecurity
Version History:(+0.57, −0.214)
Tags: LocalUserSecurity
Displays text as a regular message in the output.
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.
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.