Hello Creators!
We’re excited to announce the release of StudioTestService, a new Studio service that allows plugins to automate and customize Studio’s play test features. With StudioTestService, your plugins can launch tests that jump straight to a specific part of your game, or run complex code tests automatically.
How to Use StudioTestService
StudioTestService exposes four methods:
1. StudioTestService:ExecutePlayModeAsync(value): result
2. StudioTestService:ExecuteRunModeAsync(value): result
- Starts a test session in Play Solo or Run mode (respectively)
- The argument passed can be retrieved with GetTestArgs()
- Waits until EndTest() is called from within the test session and returns the result that was passed to it
3. StudioTestService:GetTestArgs()
- Returns the argument passed to ExecutePlayModeAsync or ExecuteRunModeAsync
4. StudioTestService:EndTest(result)
- Terminates the current test session
- Passes result back to the calling ExecuteAsync method
You can browse the full documentation for the service here.
How It Works
StudioTestService enables communication between your plugin and test sessions:
- Your plugin calls ExecutePlayModeAsync/ExecuteRunModeAsync with a test argument
- Scripts in the test session retrieve the argument with GetTestArgs()
- When testing is complete, the test calls EndTest() with the result
- Your plugin receives this result and continues execution
Plugin Script
local StudioTestService = game:GetService("StudioTestService")
local levelToTest = 2
local testResult = StudioTestService:ExecuteRunModeAsync(levelToTest)
Server Script
local StudioTestService = game:GetService("StudioTestService")
local RunService = game:GetService("RunService")
if not RunService:IsStudio() or not RunService:IsRunMode() then
return
end
local testLevel = StudioTestService:GetTestArgs()
if testLevel then
startLevel(testLevel)
else
startLevel(1)
end
We’re excited to see what you do with this new service! Please drop any feedback, suggestions, or questions below!
With many thanks,
Studio Scripting Team