Skip to content

Service · inherits Instance

TestService

Official docs ↗

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

About TestService

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.

RBX_REQUIRE

This macro does tests with calls to the TestService.Require function.

RBX_WARN

This macro does tests with calls to the TestService.Warn function.

Additional Macros

Properties 12

  • AutoRuns: booleanIf set to true, the game will start running when the service's TestService.RunAsync method is called.
  • Description: stringA description of the test being executed.
  • ErrorCount: intReadOnlyNotReplicatedMeasures how many errors have been recorded in the test session.
  • ExecuteWithStudioRun: booleanWhen set to true, TestService will be executed when using the Run action in Roblox Studio.

    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.

  • IsPhysicsEnvironmentalThrottled: booleanSets whether or not the physics environment should be throttled while running this test.
  • IsSleepAllowed: booleanSets whether or not physics objects will be allowed to fall asleep while the test simulation is running.
  • NumberOfPlayers: intThe number of players expected in this test, if any.
  • SimulateSecondsLag: doubleSets a specific amount of additional latency experienced by players during the test session.
  • TestCount: intReadOnlyNotReplicatedMeasures how many test calls have been recorded in the test session.
  • ThrottlePhysicsToRealtime: booleanSets whether the test should be throttled to simulate time according to real world time or as fast as possible.
  • Timeout: doubleThe maximum amount of time that tests are allowed to run for.
  • WarnCount: intReadOnlyNotReplicatedMeasures how many warning calls have been recorded in the test session.

Methods 11

  • Check(condition: boolean, description: string, source: Instance = nil, line: int = 0) → ()Prints result of a condition to the output.

    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.

  • Checkpoint(text: string, source: Instance = nil, line: int = 0) → ()Prints Test checkpoint: followed by a string to the output in blue text.

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

  • Done() → ()Prints Testing Done to the output in blue text.
  • Error(description: string, source: Instance = nil, line: int = 0) → ()Prints a red error message to the output, prefixed by TestService: .

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

  • Fail(description: string, source: Instance = nil, line: int = 0) → ()Indicates a fatal error in a TestService run.

    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.

  • isFeatureEnabled(name: string) → booleanReturns whether the named feature identified by name is currently enabled.

    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.

  • Message(text: string, source: Instance = nil, line: int = 0) → ()Prints TestService: followed by a string to the output in blue text.

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

  • Require(condition: boolean, description: string, source: Instance = nil, line: int = 0) → ()Prints whether a condition is true along with a description string.

    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.

  • RunAsync() → ()YieldsPluginRuns scripts which are parented to TestService.
  • ScopeTime() → DictionaryReturns a dictionary of per-scope physics simulation timings for performance testing.

    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.

  • Warn(condition: boolean, description: string, source: Instance = nil, line: int = 0) → ()Prints if a condition is true, otherwise prints a warning.

    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.

Events 2

  • ServerCollectConditionalResultTestService.ServerCollectConditionalResult:Connect(function(condition, text, script, line))Fires when the server should collect a conditional test result.
  • ServerCollectResultTestService.ServerCollectResult:Connect(function(text, script, line))Fires when the server should collect a test result.

TestService also has every member of Instance. Deprecated and Roblox-only members are hidden.

Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.