API:Class/TestService

Filtered-inheritance mode: While this class technically inherits all Instance class members, some (if not all) have been hidden because they serve no purpose for this object.
Plugin class: This object has been marked as a plugin class. Most if not all of its members are exclusive to the PluginSecurity level.
Service: This class is a service. It is a top-level singleton which can be obtained with the GetService method.

TestService icon.pngTestService : Object Icon.pngInstance

The TestService is a service used by Roblox internally to run analytical tests on their engine. It makes it possible to write sophisticated tests right inside a game.

Properties

Properties [toggle]

boolAutoRuns

If set to true, the game will start running when the TestService's Run method is called.

|RMD member="API:Class/TestService/AutoRuns"|If set to true, the game will start running when the TestService's Run method is called.|/RMD|
stringDescription

A description of the test being executed.

|RMD member="API:Class/TestService/Description"|A description of the test being executed.|/RMD|
intErrorCount [readonly]

Measures how many errors have been recorded in the test session.

|RMD member="API:Class/TestService/ErrorCount"|Measures how many errors have been recorded in the test session.|/RMD|
boolIs30FpsThrottleEnabled

Sets whether or not the physics engine should be throttled to 30 FPS while the test is being ran.

|RMD member="API:Class/TestService/Is30FpsThrottleEnabled"|Sets whether or not the physics engine should be throttled to 30 FPS while the test is being ran.|/RMD|
boolIsPhysicsEnvironmentalThrottled

Sets whether or not the physics environment should be throttled while running this test.

|RMD member="API:Class/TestService/IsPhysicsEnvironmentalThrottled"|Sets whether or not the physics environment should be throttled while running this test.|/RMD|
boolIsSleepAllowed

Sets whether or not physics objects will be allowed to fall asleep while the test simulation is running.

|RMD member="API:Class/TestService/IsSleepAllowed"|Sets whether or not physics objects will be allowed to fall asleep while the test simulation is running.|/RMD|
intNumberOfPlayers

The number of players expected in this test, if any.

|RMD member="API:Class/TestService/NumberOfPlayers"|The number of players expected in this test, if any.|/RMD|
doubleSimulateSecondsLag

Sets a specific amount of additional latency experienced by players during the test session.

|RMD member="API:Class/TestService/SimulateSecondsLag"|Sets a specific amount of additional latency experienced by players during the test session.|/RMD|
intTestCount [readonly]

Measures how many test calls have been recorded in the test session.

|RMD member="API:Class/TestService/TestCount"|Measures how many test calls have been recorded in the test session.|/RMD|
doubleTimeout

The maximum amount of time that tests are allowed to run for.

|RMD member="API:Class/TestService/Timeout"|The maximum amount of time that tests are allowed to run for.|/RMD|
intWarnCount [readonly]

Measures how many warning calls have been recorded in the test session.

|RMD member="API:Class/TestService/WarnCount"|Measures how many warning calls have been recorded in the test session.|/RMD|
If set to true, the game will start running when the TestService's Run method is called.
A description of the test being executed.
ErrorCount [readonly]
Measures how many errors have been recorded in the test session.
Sets whether or not the physics engine should be throttled to 30 FPS while the test is being ran.
Sets whether or not the physics environment should be throttled while running this test.
Sets whether or not physics objects will be allowed to fall asleep while the test simulation is running.
The number of players expected in this test, if any.
Sets a specific amount of additional latency experienced by players during the test session.
TestCount [readonly]
Measures how many test calls have been recorded in the test session.
The maximum amount of time that tests are allowed to run for.
WarnCount [readonly]
Measures how many warning calls have been recorded in the test session.

Functions

Functions [toggle]

voidCheck ( bool condition, string description, LuaSourceContainer source = nil, int line = 0 )

Prints result of condition to output.

|RMD member="API:Class/TestService/Check"|Prints result of condition to output.|/RMD|
voidCheckpoint ( string text, LuaSourceContainer source = nil, int line = 0 )

Prints "Test checkpoint: ", followed by text, to the output, in blue text.

|RMD member="API:Class/TestService/Checkpoint"|Prints "Test checkpoint: ", followed by text, to the output, in blue text.|/RMD|
voidDone ( )

Prints Testing Done to the output, in blue text.

|RMD member="API:Class/TestService/Done"|Prints Testing Done to the output, in blue text.|/RMD|
voidError ( string description, LuaSourceContainer source = nil, int line = 0 )

Prints a red message to the output.

|RMD member="API:Class/TestService/Error"|Prints a red message to the output.|/RMD|
voidFail ( string description, LuaSourceContainer source = nil, int line = 0 )

Indicates a fatal error in a TestService run. If this is called inside of a script running inside of the TestService, this will initiate a breakpoint on the line that invoked the error.

|RMD member="API:Class/TestService/Fail"|Indicates a fatal error in a TestService run.

If this is called inside of a script running inside of the TestService, this will initiate a breakpoint on the line that invoked the error.|/RMD|

voidMessage ( string text, LuaSourceContainer source = nil, int line = 0 )

Prints Test message, followed by text to the output, in blue text.

|RMD member="API:Class/TestService/Message"|Prints Test message, followed by text to the output, in blue text.|/RMD|
voidRequire ( bool condition, string description, LuaSourceContainer source = nil, int line = 0 )

Prints whether a condition is true along with description text.

|RMD member="API:Class/TestService/Require"|Prints whether a condition is true along with description text.|/RMD|
voidWarn ( bool condition, string description, LuaSourceContainer source = nil, int line = 0 )

Prints if a condition is true, otherwise prints a warning.

|RMD member="API:Class/TestService/Warn"|Prints if a condition is true, otherwise prints a warning.|/RMD|
Check ( bool condition, string description, LuaSourceContainer source = nil, int line = 0 )
Prints result of condition to output.
Checkpoint ( string text, LuaSourceContainer source = nil, int line = 0 )
Prints "Test checkpoint: ", followed by text, to the output, in blue text.
Done ( )
Prints Testing Done to the output, in blue text.
Error ( string description, LuaSourceContainer source = nil, int line = 0 )
Prints a red message to the output.
Fail ( string description, LuaSourceContainer source = nil, int line = 0 )
Indicates a fatal error in a TestService run. If this is called inside of a script running inside of the TestService, this will initiate a breakpoint on the line that invoked the error.
Message ( string text, LuaSourceContainer source = nil, int line = 0 )
Prints Test message, followed by text to the output, in blue text.
Require ( bool condition, string description, LuaSourceContainer source = nil, int line = 0 )
Prints whether a condition is true along with description text.
Warn ( bool condition, string description, LuaSourceContainer source = nil, int line = 0 )
Prints if a condition is true, otherwise prints a warning.

YieldFunctions

YieldFunctions [toggle]

voidRun ( ) [PluginSecurity]

Runs scripts which are parented to TestService.

|RMD member="API:Class/TestService/Run"|Runs scripts which are parented to TestService.|/RMD|
Run ( ) [PluginSecurity]
Runs scripts which are parented to TestService.

Events

Events [toggle]

ServerCollectConditionalResult ( bool condition, string text, LuaSourceContainer script, int line )

Fired when the server should collect a conditional test result.

|RMD member="API:Class/TestService/ServerCollectConditionalResult"|Fired when the server should collect a conditional test result.|/RMD|
ServerCollectResult ( string text, LuaSourceContainer script, int line )

Fired when the server should collect a test result.

|RMD member="API:Class/TestService/ServerCollectResult"|Fired when the server should collect a test result.|/RMD|
Fired when the server should collect a conditional test result.
Fired when the server should collect a test result.

|RMD member="API:Class/TestService"|The TestService is a service used by Roblox internally to run analytical tests on their engine. It makes it possible to write sophisticated tests right inside a game. |/RMD|

Macros

Scripts that are executed inside of the TestService (via Run) have access to special macros, that directly invoke methods under the TestService.
Macros are essentially substitutions for large blocks of code that shouldn't need to be rewritten each time you want to call them.

RBX_CHECK

This macro does tests with calls to the TestService's Check method.

Macro Test Condition
RBX_CHECK(cond) cond == true
RBX_CHECK_MESSAGE(cond, failMsg) cond == true
RBX_CHECK_THROW(CODE) pcall(function () CODE end) == false
RBX_CHECK_NO_THROW(CODE) pcall(function () CODE end) == true
RBX_CHECK_EQUAL(a,b) a == b
RBX_CHECK_NE(a,b) a ~= b
RBX_CHECK_GE(a,b) a >= b
RBX_CHECK_LE(a,b) a <= b
RBX_CHECK_GT(a,b) a > b
RBX_CHECK_LT(a,b) a < b

RBX_REQUIRE

This macro does tests with calls to the TestService's Require method.

Macro Test Condition
RBX_REQUIRE(cond) cond == true
RBX_REQUIRE_MESSAGE(cond, failMsg) cond == true
RBX_REQUIRE_THROW(CODE) pcall(function () CODE end) == false
RBX_REQUIRE_NO_THROW(CODE) pcall(function () CODE end) == true
RBX_REQUIRE_EQUAL(a,b) a == b
RBX_REQUIRE_NE(a,b) a ~= b
RBX_REQUIRE_GE(a,b) a >= b
RBX_REQUIRE_LE(a,b) a <= b
RBX_REQUIRE_GT(a,b) a > b
RBX_REQUIRE_LT(a,b) a < b

RBX_WARN

This macro does tests with calls to the TestService's Warn method.

Macro Test Condition
RBX_WARN(cond) cond == true
RBX_WARN_MESSAGE(cond, failMsg) cond == true
RBX_WARN_THROW(CODE) pcall(function () CODE end) == false
RBX_WARN_NO_THROW(CODE) pcall(function () CODE end) == true
RBX_WARN_EQUAL(a,b) a == b
RBX_WARN_NE(a,b) a ~= b
RBX_WARN_GE(a,b) a >= b
RBX_WARN_LE(a,b) a <= b
RBX_WARN_GT(a,b) a > b
RBX_WARN_LT(a,b) a < b

Additional Macros

Macro Description
RBX_ERROR(msg) Directly calls the TestService's Error method.
RBX_FAIL(msg) Directly calls the TestService's Fail method.
RBX_MESSAGE(msg) Directly calls the TestService's Message method.
RBX_CHECKPOINT(msg) Directly calls the TestService's Checkpoint method.

See also