We use cookies on this site to enhance your user experience

TestService

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.

Macros

Scripts that are executed inside of the TestService (via TestService/Run) have access to special macros that directly invoke functions 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/Check function.

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/Require function.

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/Warn function.

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/Error` function.
RBX_FAIL(msg) Directly calls the `TestService/Fail` function.
RBX_MESSAGE(msg) Directly calls the `TestService/Message` function.

See Also

Properties

Name Type Description
bool

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

string

A description of the test being executed.

int

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

bool

When set to true, the TestService will be executed when using the Run action in Roblox Studio.

bool

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

bool

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

bool

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

int

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

double

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

int

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

double

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

int

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

Inherited from Instance

Archivable ClassName DataCost Name Parent RobloxLocked

Functions

Name Type Description
void

Prints result of condition to output.

void

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

void

Prints Testing Done to the output, in blue text.

void

Prints a red message to the output.

void

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.

void

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

void

Prints whether a condition is true along with description text.

Run

void

Runs scripts which are parented to TestService.

void

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

bool

Inherited from Instance

ClearAllChildren Clone Destroy FindFirstAncestor FindFirstAncestorOfClass FindFirstAncestorWhichIsA FindFirstChild FindFirstChildOfClass FindFirstChildWhichIsA GetChildren GetDebugId GetDescendants GetFullName GetPropertyChangedSignal IsA IsAncestorOf IsDescendantOf WaitForChild

Events

Name Type Description

Fired when the server should collect a conditional test result.

Fired when the server should collect a test result.

Inherited from Instance

AncestryChanged Changed ChildAdded ChildRemoved DescendantAdded DescendantRemoving