# This file is automatically generated. Please don't edit it manually. # To submit a bug report on the content, see # https://devforum.roblox.com/c/bug-reports/documentation-issues/72 name: StudioTestService type: class memory_category: Instances summary: | Service allowing plugins to automate and customize Test and Run mode testing. description: | `StudioTestService` allows plugins to automate and customize Test and Run mode testing. With StudioTestService, your plugins can launch tests that jump straight to a specific part of your game, or run complex code tests automatically. The following is an example of automated unit testing: ```lua --Plugin Script local StudioTestService = game:GetService("StudioTestService") local testResult = StudioTestService:ExecuteRunModeAsync("MyTestSuite") print("Test finished. Result:", testResult) ``` ```lua --Server Script local StudioTestService = game:GetService("StudioTestService") local RunService = game:GetService("RunService") if not RunService:IsStudio() or not RunService:IsRunMode() then return end local suiteName = StudioTestService:GetTestArgs() if suiteName then local tests = getTestsArrayByName(SuiteName) if tests then local result = "SUCCESS!" for name, test in tests do if not pcall(test) then result = name .. " failed!" break end end StudioTestService:EndTest(result) else StudioTestService:EndTest("Suite not found") end else print("Starting manual playtest") end ``` code_samples: [] inherits: - Instance descendants: [] tags: - NotCreatable - Service - NotReplicated deprecation_message: '' properties: [] methods: - name: StudioTestService:EndTest summary: '' description: | Ends the current Studio test session if called from the server `Class.DataModel`, even if the test was not started by this service. If the test was started by `Class.StudioTestService:ExecutePlayModeAsync()` or `Class.StudioTestService:ExecuteRunModeAsync()`, the value passed here is returned by that method. This method returns immediately and ends the test session asynchronously. It errors if called from any `Class.DataModel` other than that of the server during a running Studio test session. code_samples: [] parameters: - name: value type: Variant default: summary: | Value returned to the calling `Class.StudioTestService:ExecutePlayModeAsync()` or `Class.StudioTestService:ExecuteRunModeAsync()` method. returns: - type: () summary: '' tags: [] deprecation_message: '' security: None thread_safety: Unsafe capabilities: [] - name: StudioTestService:ExecutePlayModeAsync summary: '' description: | Starts a solo **Test** session and yields until that session ends. The `args` parameter can be retrieved using `Class.StudioTestService:GetTestArgs()`. Returns the value passed to `Class.StudioTestService:EndTest()`, or `nil` if the test ended by other means. This method errors if a test session is already running. code_samples: [] parameters: - name: args type: Variant default: summary: | Argument passed to the test session, or `nil`. returns: - type: Variant summary: | Value passed from `Class.StudioTestService:EndTest()`, or `nil`. tags: - Yields deprecation_message: '' security: PluginSecurity thread_safety: Unsafe capabilities: [] - name: StudioTestService:ExecuteRunModeAsync summary: '' description: | Starts a **Run** test session and yields until that session ends. The `args` parameter can be retrieved using `Class.StudioTestService:GetTestArgs()`. Returns the value passed to `Class.StudioTestService:EndTest()`, or `nil` if the test ended by other means. This method errors if a test session is already running. code_samples: [] parameters: - name: args type: Variant default: summary: | Argument passed to the test session, or `nil`. returns: - type: Variant summary: | Value passed from `Class.StudioTestService:EndTest()`, or `nil`. tags: - Yields deprecation_message: '' security: PluginSecurity thread_safety: Unsafe capabilities: [] - name: StudioTestService:GetTestArgs summary: '' description: | Returns the argument passed to `Class.StudioTestService:ExecutePlayModeAsync()` or `Class.StudioTestService:ExecuteRunModeAsync()` for the current test session, or `nil` if the session was not started by those methods. code_samples: [] parameters: [] returns: - type: Variant summary: | Arguments passed to the test, or `nil`. tags: [] deprecation_message: '' security: None thread_safety: Unsafe capabilities: [] events: [] callbacks: []