TestService

Show Deprecated
Service

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.

MacroTest 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.

MacroTest 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.

MacroTest 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

MacroDescription
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.

Summary

Properties

  • Read Parallel

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

  • Read Parallel

    A description of the test being executed.

  • Read Only
    Not Replicated
    Read Parallel

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

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

  • Not Replicated
    Deprecated
    Read Parallel

    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.

  • Read Parallel

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

  • Read Parallel

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

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

  • Read Only
    Not Replicated
    Read Parallel

    Sets whether the test should be throttled to simulate time according to real world time or as fast as possible.

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

  • Read Parallel

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

  • Read Only
    Not Replicated
    Read Parallel

Methods

Events

Properties

AutoRuns

Read Parallel

Description

Read Parallel

ErrorCount

Read Only
Not Replicated
Read Parallel

ExecuteWithStudioRun

Read Parallel

Is30FpsThrottleEnabled

Not Replicated
Deprecated
Read Parallel

IsPhysicsEnvironmentalThrottled

Read Parallel

IsSleepAllowed

Read Parallel

NumberOfPlayers

Read Parallel

SimulateSecondsLag

Read Parallel

TestCount

Read Only
Not Replicated
Read Parallel

ThrottlePhysicsToRealtime

Read Parallel

Timeout

Read Parallel

WarnCount

Read Only
Not Replicated
Read Parallel

Methods

Check

()

Parameters

condition: boolean
description: string
source: Instance
Default Value: "nil"
line: number
Default Value: 0

Returns

()

Code Samples

TestService:Check

local TestService = game:GetService("TestService")
TestService:Check(false, "example")

Checkpoint

()

Parameters

text: string
source: Instance
Default Value: "nil"
line: number
Default Value: 0

Returns

()

Code Samples

TestService:Checkpoint

local TestService = game:GetService("TestService")
TestService:Checkpoint("example")

Done

()

Returns

()

Code Samples

TestService:Done

local TestService = game:GetService("TestService")
TestService:Done()

Error

()

Parameters

description: string
source: Instance
Default Value: "nil"
line: number
Default Value: 0

Returns

()

Code Samples

TestService:Error

local TestService = game:GetService("TestService")
TestService:Error("this is an error")

Fail

()

Parameters

description: string
source: Instance
Default Value: "nil"
line: number
Default Value: 0

Returns

()

Message

()

Parameters

text: string
source: Instance
Default Value: "nil"
line: number
Default Value: 0

Returns

()

Code Samples

TestService:Message

local TestService = game:GetService("TestService")
TestService:Message("example")

Require

()

Parameters

condition: boolean
description: string
source: Instance
Default Value: "nil"
line: number
Default Value: 0

Returns

()

Code Samples

TestService:Require

local TestService = game:GetService("TestService")
TestService:Require(false, "example")

Run

()
Yields
Plugin Security

Returns

()

ScopeTime


Returns

TakeSnapshot

()

Parameters

snapshotname: string

Returns

()

Warn

()

Parameters

condition: boolean
description: string
source: Instance
Default Value: "nil"
line: number
Default Value: 0

Returns

()

Code Samples

TestService:Warn

local TestService = game:GetService("TestService")
TestService:Warn(false, "this action is invalid")

isFeatureEnabled

Parameters

name: string

Returns

Events

ServerCollectConditionalResult

Parameters

condition: boolean
text: string
script: Instance
line: number

ServerCollectResult

Parameters

text: string
script: Instance
line: number