Reference API Roblox

Engine API

Website

Related

Reference API Roblox

TestService

A service used by Roblox to run controlled tests of the engine. It is available for developers to use, to a limited degree.

This class is a service. It is a singleton that may be acquired with GetService.
Tags: [Service]

Member index 25

HistoryMember
553AutoRuns: bool
486Description: string
553ErrorCount: int
553ExecuteWithStudioRun: bool
640Is30FpsThrottleEnabled: bool
640IsPhysicsEnvironmentalThrottled: bool
553IsSleepAllowed: bool
553NumberOfPlayers: int
553SimulateSecondsLag: double
553TestCount: int
553Timeout: double
553WarnCount: int
573Check(condition: bool, description: string, source: Instance = Instance, line: int = 0): null
573Checkpoint(text: string, source: Instance = Instance, line: int = 0): null
573Done(): null
573Error(description: string, source: Instance = Instance, line: int = 0): null
573Fail(description: string, source: Instance = Instance, line: int = 0): null
573Message(text: string, source: Instance = Instance, line: int = 0): null
573Require(condition: bool, description: string, source: Instance = Instance, line: int = 0): null
573Run(): null
486ScopeTime(): Dictionary
573Warn(condition: bool, description: string, source: Instance = Instance, line: int = 0): null
462isFeatureEnabled(name: string): bool
462ServerCollectConditionalResult(condition: bool, text: string, script: Instance, line: int)
462ServerCollectResult(text: string, script: Instance, line: int)
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
580IsPropertyModified(name: string): bool
573Remove(): null
576RemoveTag(tag: string): null
580ResetPropertyToDefault(name: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Removed member index 4

HistoryMember
214DoCommand(name: string): void
214GetCommandNames(): Array
214IsCommandChecked(name: string): bool
214IsCommandEnabled(name: string): bool

Description

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.

History 116

Members 25

AutoRuns

TypeDefault
booltrue

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

History 4

Check

Parameters (4)Default
conditionbool
descriptionstring
sourceInstanceInstance
lineint0
Returns (1)
null

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

History 4

Checkpoint

Parameters (3)Default
textstring
sourceInstanceInstance
lineint0
Returns (1)
null

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

History 4

Description

TypeDefault
string

A description of the test being executed.

History 3

Done

Parameters (0)
No parameters.
Returns (1)
null

Prints Testing Done to the output, in blue text.

History 3

Error

Parameters (3)Default
descriptionstring
sourceInstanceInstance
lineint0
Returns (1)
null

Prints a red message to the output, prefixed by TestService: .

History 3

ErrorCount

TypeDefault
int0

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

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 4

Tags: [ReadOnly, NotReplicated]

ExecuteWithStudioRun

TypeDefault
boolfalse

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

Note:

  • If the TestService.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 at most), or else your computer's CPU will get overloaded.

History 4

Fail

Parameters (3)Default
descriptionstring
sourceInstanceInstance
lineint0
Returns (1)
null

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.

History 3

Is30FpsThrottleEnabled

TypeDefault
booltrue

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

History 8

IsPhysicsEnvironmentalThrottled

TypeDefault
booltrue

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

History 8

IsSleepAllowed

TypeDefault
booltrue

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

History 4

Message

Parameters (3)Default
textstring
sourceInstanceInstance
lineint0
Returns (1)
null

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

History 4

NumberOfPlayers

TypeDefault
int0

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

History 8

Require

Parameters (4)Default
conditionbool
descriptionstring
sourceInstanceInstance
lineint0
Returns (1)
null

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, to the output in red text.

History 4

Run

Parameters (0)
No parameters.
Returns (1)
null

Runs scripts which are parented to TestService.

This function yields. It will block the calling thread until completion.

History 4

  • 573 Change ReturnType of Run from void to null
  • 462 Change ThreadSafety of Run from to Unsafe
  • 151 Change Security of Run from LocalUserSecurity to PluginSecurity
  • 52 Add Run
Tags: [Yields]

ScopeTime

Parameters (0)
No parameters.
Returns (1)
Dictionary

History 1

ServerCollectConditionalResult

Parameters (4)
conditionbool
textstring
scriptInstance
lineint

Fired when the server should collect a conditional test result.

History 6

ServerCollectResult

Parameters (3)
textstring
scriptInstance
lineint

Fired when the server should collect a test result.

History 6

SimulateSecondsLag

TypeDefault
double0

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

History 4

TestCount

TypeDefault
int0

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

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 4

Tags: [ReadOnly, NotReplicated]

Timeout

TypeDefault
double10

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

History 4

Warn

Parameters (4)Default
conditionbool
descriptionstring
sourceInstanceInstance
lineint0
Returns (1)
null

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.

History 4

WarnCount

TypeDefault
int0

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

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 4

Tags: [ReadOnly, NotReplicated]

isFeatureEnabled

Parameters (1)
namestring
Returns (1)
bool

History 2

Removed members 4

DoCommand

Parameters (1)
namestring
Returns (1)
void

History 2

GetCommandNames

Parameters (0)
No parameters.
Returns (1)
Array

History 2

IsCommandChecked

Parameters (1)
namestring
Returns (1)
bool

History 2

IsCommandEnabled

Parameters (1)
namestring
Returns (1)
bool

History 2

Settings