15 min read

Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.

TestService

Inherits from: Instance → Object

TestService is a service used by Roblox internally to run analytical tests on the engine.

Scripts that are executed inside of TestService (via TestService:RunAsync()) have access to special macros that directly invoke functions under the service. 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 Class.TestService:Error() function.
RBX_FAIL(msg) Directly calls the Class.TestService:Fail() function.
RBX_MESSAGE(msg) Directly calls the Class.TestService:Message() function.

Inherits from: Instance

Memory category: Instances

Tags: Service

Properties

NameType / ReturnsDescription
TestService.AutoRunsbooleanIf set to true, the game will start running when the service's TestService:RunAsync() method is called.
TestService.DescriptionstringA description of the test being executed.
TestService.ErrorCountintMeasures how many errors have been recorded in the test session.
TestService.ExecuteWithStudioRunbooleanWhen set to true, TestService will be executed when using the Run action in Roblox Studio.
TestService.Is30FpsThrottleEnabledbooleanSets whether or not the physics engine should be throttled to 30 FPS while the test is being ran.
TestService.IsPhysicsEnvironmentalThrottledbooleanSets whether or not the physics environment should be throttled while running this test.
TestService.IsSleepAllowedbooleanSets whether or not physics objects will be allowed to fall asleep while the test simulation is running.
TestService.NumberOfPlayersintThe number of players expected in this test, if any.
TestService.SimulateSecondsLagdoubleSets a specific amount of additional latency experienced by players during the test session.
TestService.TestCountintMeasures how many test calls have been recorded in the test session.
TestService.ThrottlePhysicsToRealtimebooleanSets whether the test should be throttled to simulate time according to real world time or as fast as possible.
TestService.TimeoutdoubleThe maximum amount of time that tests are allowed to run for.
TestService.WarnCountintMeasures how many warning calls have been recorded in the test session.

Inherited from Instance

NameType / ReturnsDescription
Instance.ArchivablebooleanDetermines if an Instance and its descendants can be cloned using Instance:Clone(), and can be saved/published.
Instance.archivableboolean
Instance.CapabilitiesSecurityCapabilitiesThe set of capabilities allowed to be used for scripts inside this container.
Instance.IsInSandboxbooleanIndicates whether the instance is inside a sandboxed container.
Instance.NamestringA non-unique identifier of the Instance.
Instance.ParentInstanceDetermines the hierarchical parent of the Instance.
Instance.PredictionModePredictionModeReflects the client-side prediction mode applied to the instance under server-authoritative physics.
Instance.RobloxLockedbooleanA deprecated property that used to protect CoreGui objects.
Instance.SandboxedbooleanWhen enabled, the instance can only access abilities in its Capabilities list.
Instance.UniqueIdUniqueIdA unique identifier for the instance.

Inherited from Object

NameType / ReturnsDescription
Object.ClassNamestringA read-only string representing the class this Object belongs to.
Object.classNamestring

TestService.AutoRuns

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

FieldValue
typeboolean
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryPhysics
serialization{"can_load":true,"can_save":true}

TestService.Description

A description of the test being executed.

FieldValue
typestring
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryData
serialization{"can_load":true,"can_save":true}

TestService.ErrorCount

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

FieldValue
typeint
tags["ReadOnly","NotReplicated"]
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryResults
serialization{"can_load":false,"can_save":true}

TestService.ExecuteWithStudioRun

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

Note that if the NumberOfPlayers property is set to a value above 0, running the game will open NumberOfPlayers + 1 Studio windows where one window is a server and the rest are players connected to that server. Try to keep this value within a rational range (1 to 8 players) or else your computer's CPU will get overloaded.

FieldValue
typeboolean
security{"read":"None","write":"None"}
thread safetyReadSafe
categorySettings
serialization{"can_load":true,"can_save":true}

TestService.Is30FpsThrottleEnabled

Deprecated. This has been deprecated and directly renamed to ThrottlePhysicsToRealtime to better reflect its practical use.

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

FieldValue
typeboolean
tags["NotReplicated","Deprecated"]
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryPhysics
serialization{"can_load":true,"can_save":false}

TestService.IsPhysicsEnvironmentalThrottled

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

FieldValue
typeboolean
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryPhysics
serialization{"can_load":true,"can_save":true}

TestService.IsSleepAllowed

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

FieldValue
typeboolean
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryPhysics
serialization{"can_load":true,"can_save":true}

TestService.NumberOfPlayers

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

FieldValue
typeint
security{"read":"None","write":"None"}
thread safetyReadSafe
categorySettings
serialization{"can_load":true,"can_save":true}

TestService.SimulateSecondsLag

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

FieldValue
typedouble
security{"read":"None","write":"None"}
thread safetyReadSafe
categorySettings
serialization{"can_load":true,"can_save":true}

TestService.TestCount

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

FieldValue
typeint
tags["ReadOnly","NotReplicated"]
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryResults
serialization{"can_load":false,"can_save":true}

TestService.ThrottlePhysicsToRealtime

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

FieldValue
typeboolean
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryPhysics
serialization{"can_load":true,"can_save":true}

TestService.Timeout

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

FieldValue
typedouble
security{"read":"None","write":"None"}
thread safetyReadSafe
categorySettings
serialization{"can_load":true,"can_save":true}

TestService.WarnCount

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

FieldValue
typeint
tags["ReadOnly","NotReplicated"]
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryResults
serialization{"can_load":false,"can_save":true}

Methods

NameType / ReturnsDescription
TestService:Check()Prints result of a condition to the output.
TestService:Checkpoint()Prints Test checkpoint: followed by a string to the output in blue text.
TestService:Done()Prints Testing Done to the output in blue text.
TestService:Error()Prints a red error message to the output, prefixed by TestService: .
TestService:Fail()Indicates a fatal error in a TestService run.
TestService:isFeatureEnabledbooleanReturns whether the named feature identified by name is currently enabled.
TestService:Message()Prints TestService: followed by a string to the output in blue text.
TestService:Require()Prints whether a condition is true along with a description string.
TestService:Run()Runs scripts which are parented to TestService.
TestService:RunAsync()Runs scripts which are parented to TestService.
TestService:ScopeTimeDictionaryReturns a dictionary of per-scope physics simulation timings for performance testing.
TestService:Warn()Prints if a condition is true, otherwise prints a warning.

Inherited from Instance

NameType / ReturnsDescription
Instance:AddTag()Applies a tag to the instance.
Instance:childrenInstancesReturns an array of the object's children.
Instance:ClearAllChildren()This method destroys all of an instance's children.
Instance:CloneInstanceCreate a copy of an instance and all its descendants, ignoring instances that are not Archivable.
Instance:cloneInstance
Instance:Destroy()Sets the Instance.Parent property to nil, locks the Instance.Parent property, disconnects all connections, and calls Destroy() on all children.
Instance:destroy()
Instance:FindFirstAncestorInstance?Returns the first ancestor of the Instance whose Instance.Name is equal to the given name.
Instance:FindFirstAncestorOfClassInstance?Returns the first ancestor of the Instance whose Object.ClassName is equal to the given className.
Instance:FindFirstAncestorWhichIsAInstance?Returns the first ancestor of the Instance for whom Object:IsA() returns true for the given className.
Instance:FindFirstChildInstance?Returns the first child of the Instance found with the given name.
Instance:findFirstChildInstance
Instance:FindFirstChildOfClassInstance?Returns the first child of the Instance whose ClassName is equal to the given class name.
Instance:FindFirstChildWhichIsAInstance?Returns the first child of the Instance for whom Object:IsA() returns true for the given className.
Instance:FindFirstDescendantInstance?Returns the first descendant found with the given Instance.Name.
Instance:GetActorActor?Returns the Actor associated with the Instance, if any.
Instance:GetAttributeVariantReturns the value which has been assigned to the given attribute name.
Instance:GetAttributeChangedSignalRBXScriptSignalReturns an event that fires when the given attribute changes.
Instance:GetAttributesDictionaryReturns a dictionary of the instance's attributes.
Instance:GetChildrenInstancesReturns an array containing all of the instance's children.
Instance:getChildrenInstances
Instance:GetDebugIdstringReturns a coded string of the debug ID used internally by Roblox.
Instance:GetDescendantsInstancesReturns an array containing all of the descendants of the instance.
Instance:GetFullNamestringReturns a string describing the instance's ancestry.
Instance:GetStyledVariantReturns the styled or explicitly modified value of the specified property, or else the default property value if it hasn't been styled/modified.
Instance:GetStyledPropertyChangedSignalRBXScriptSignalReturns an event that fires when the given style property changes on the instance.
Instance:GetTagsArrayGets an array of all tags applied to the instance.
Instance:HasTagbooleanCheck whether the instance has a given tag.
Instance:IsAncestorOfbooleanReturns true if an Instance is an ancestor of the given descendant.
Instance:IsDescendantOfbooleanReturns true if an Instance is a descendant of the given ancestor.
Instance:isDescendantOfboolean
Instance:IsPropertyModifiedbooleanReturns true if the value stored in the specified property is not equal to the code-instantiated default.
Instance:QueryDescendantsInstancesReturns an array containing all descendants of the instance that match the selector string.
Instance:Remove()Sets the object's Parent to nil, and does the same for all its descendants.
Instance:remove()
Instance:RemoveTag()Removes a tag from the instance.
Instance:ResetPropertyToDefault()Resets a property to its default value.
Instance:SetAttribute()Sets the attribute with the given name to the given value.
Instance:WaitForChildInstanceReturns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does.

Inherited from Object

NameType / ReturnsDescription
Object:GetPropertyChangedSignalRBXScriptSignalGet an event that fires when a given property of the object changes.
Object:IsAbooleanReturns true if an object's class matches or inherits from a given class.
Object:isAboolean

TestService:Check

If condition is true, prints Check passed: followed by description to the output in blue text. Otherwise, prints Check failed: followed by description in red text.

Parameters

NameTypeDefaultDescription
conditionbooleanThe boolean expression to evaluate as the test assertion.
descriptionstringA label that identifies this check in the test output.
sourceInstancenilThe script instance that invoked the check, used for output attribution. Defaults to nil.
lineint0The line number in the source script where the check was called. Defaults to 0.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe

Code samples: View on Creator Hub (TestService-Check1).

TestService:Checkpoint

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

Parameters

NameTypeDefaultDescription
textstringThe message to print alongside the checkpoint label.
sourceInstancenilThe script instance that invoked the checkpoint, used for output attribution. Defaults to nil.
lineint0The line number in the source script where the checkpoint was called. Defaults to 0.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe

Code samples: View on Creator Hub (TestService-Checkpoint1).

TestService:Done

Prints Testing Done to the output in blue text.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe

Code samples: View on Creator Hub (TestService-Done1).

TestService:Error

Prints a red error message (description) to the output, prefixed by TestService: .

Parameters

NameTypeDefaultDescription
descriptionstringThe error message text to display.
sourceInstancenilThe script instance that raised the error, used for output attribution. Defaults to nil.
lineint0The line number in the source script where the error was raised. Defaults to 0.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe

Code samples: View on Creator Hub (TestService-Error1).

TestService:Fail

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

Parameters

NameTypeDefaultDescription
descriptionstringThe failure message text to display.
sourceInstancenilThe script instance where the failure occurred, used for output attribution. Defaults to nil.
lineint0The line number in the source script where the failure was triggered. Defaults to 0.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe

TestService:isFeatureEnabled

Returns true if the feature identified by name is set to true, and false if it is set to any other value. Raises an error if name doesn't correspond to a defined feature.

Parameters

NameTypeDefaultDescription
namestringThe name of the feature to query.

Returns

TypeDescription
booleantrue if the named feature resolves to true, false otherwise.
FieldValue
securityNone
thread safetyUnsafe

TestService:Message

Prints TestService: followed by text to the output in blue text.

Parameters

NameTypeDefaultDescription
textstringThe message to print to the output.
sourceInstancenilThe script instance that sent the message, used for output attribution. Defaults to nil.
lineint0The line number in the source script where the message was sent. Defaults to 0.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe

Code samples: View on Creator Hub (TestService-Message1).

TestService:Require

If condition is true, prints Require passed: followed by description to the output in blue text. Otherwise prints Require failed. Test ended: followed by description in red text.

Parameters

NameTypeDefaultDescription
conditionbooleanThe boolean expression to evaluate as a required assertion.
descriptionstringA label that identifies this requirement in the test output.
sourceInstancenilThe script instance that invoked the requirement, used for output attribution. Defaults to nil.
lineint0The line number in the source script where the requirement was called. Defaults to 0.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe

Code samples: View on Creator Hub (TestService-Require1).

TestService:Run

Deprecated. Use RunAsync() instead.

Runs scripts which are parented to TestService.

Returns

TypeDescription
()
FieldValue
tags["Yields","Deprecated"]
securityPluginSecurity
thread safetyUnsafe

TestService:RunAsync

Runs scripts which are parented to TestService.

Returns

TypeDescription
()
FieldValue
tags["Yields"]
securityPluginSecurity
thread safetyUnsafe

TestService:ScopeTime

Returns a dictionary mapping physics simulation scopes to their measured step times, used for per-scope physics performance testing. Raises an error if the caller lacks permission.

Returns

TypeDescription
DictionaryA dictionary mapping physics simulation scopes to their measured step times.
FieldValue
securityNone
thread safetyUnsafe

TestService:Warn

If condition is true, prints Warning passed: followed by description to the output in blue text. Otherwise prints Warning: followed by description to the output in yellow text.

Parameters

NameTypeDefaultDescription
conditionbooleanThe boolean expression to evaluate as the warning assertion.
descriptionstringA label that identifies this warning check in the test output.
sourceInstancenilThe script instance that invoked the warning, used for output attribution. Defaults to nil.
lineint0The line number in the source script where the warning was called. Defaults to 0.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe

Code samples: View on Creator Hub (TestService-Warn1).

Events

NameType / ReturnsDescription
TestService.ServerCollectConditionalResultFires when the server should collect a conditional test result.
TestService.ServerCollectResultFires when the server should collect a test result.

Inherited from Instance

NameType / ReturnsDescription
Instance.AncestryChangedFires when the Instance.Parent property of this object or one of its ancestors is changed.
Instance.AttributeChangedFires whenever an attribute is changed on the Instance.
Instance.ChildAddedFires after an object is parented to this Instance.
Instance.childAdded
Instance.ChildRemovedFires after a child is removed from this Instance.
Instance.DescendantAddedFires after a descendant is added to the Instance.
Instance.DescendantRemovingFires immediately before a descendant of the Instance is removed.
Instance.DestroyingFires immediately before (or is deferred until after) the instance is destroyed via Instance:Destroy().
Instance.StyledPropertiesChangedFires whenever any style property is changed on the instance, including when a property is set to nil.

Inherited from Object

NameType / ReturnsDescription
Object.ChangedFires immediately after a property of the object changes, with some limitations.

TestService.ServerCollectConditionalResult

Fires when the server should collect a conditional test result.

Parameters

NameTypeDefaultDescription
conditionbooleanWhether the conditional test assertion passed or failed.
textstringThe description label associated with the test assertion.
scriptInstanceThe script instance that produced the result.
lineintThe line number in the script where the assertion was made.
FieldValue
securityNone

TestService.ServerCollectResult

Fires when the server should collect a test result.

Parameters

NameTypeDefaultDescription
textstringThe result message text sent from the client.
scriptInstanceThe script instance that produced the result.
lineintThe line number in the script where the result was generated.
FieldValue
securityNone