StudioTestService
Service allowing plugins to automate and customize Test and Run mode testing.
| Memory category | Instances |
|---|
Member index 5
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.
You can use StudioTestService to start a server with multiple simulated
clients, add players mid-session, pass arguments into running tests, end tests
from the server, and trigger client disconnections, all without manually
clicking through the Test tab in Studio.
These methods complement the existing playtest automation available through
Studio's built-in MCP server. Where the MCP server's start_stop_play tool
starts a single Play Client session, the StudioTestService methods are
designed for scripted multi-client scenarios such as lobby, matchmaking, and
join/leave flow testing.
A typical multiplayer test splits across three script contexts: the plugin that launches it, the server that drives it, and the clients that participate:
Plugin script:
1 2 3 4 5 6 7 8 9 10 11 12 | |
Server script:
1 2 3 4 5 6 7 8 9 10 | |
Client script:
1 2 3 4 5 6 7 | |
Limitations
ExecuteMultiplayerTestAsynccan only be called from plugin scripts. It yields until the test ends, so wrap it in a coroutine if the calling plugin needs to remain responsive.ExecuteMultiplayerTestAsynccannot be called from inside a running test.ExecuteMultiplayerTestAsyncsupports up to 8 simulated clients per test session.- Only one multiplayer test session can run at a time per Studio instance.
AddPlayersandEndTestmust be called from the server DataModel of a running test.CanLeaveTestandLeaveTestmust be called from a client DataModel.GetTestArgscurrently has a known issue when called from a client LocalScript.
History 6
- 712 Add EditModeActive
- 700 Add GetTestArgs
- 700 Add ExecuteRunModeAsync
- 700 Add ExecutePlayModeAsync
- 700 Add EndTest
- 700 Add StudioTestService
Members 5
EditModeActive
| Type | Default | |
|---|---|---|
| bool | true | |
| Security | PluginSecurity |
|---|---|
| Thread safety | ReadSafe |
| Category | Data |
| Loaded/Saved | true |
History 1
- 712 Add EditModeActive
EndTest
| Parameters (1) | ||
|---|---|---|
| value | Variant | |
| Returns (1) | ||
| null | ||
Ends the current Studio test session if called from the server DataModel, even if the test was not started by this service.
If the test was started by StudioTestService:ExecutePlayModeAsync() or 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 DataModel other than that of the server during a running Studio test session.
| Thread safety | Unsafe |
|---|
ExecutePlayModeAsync
| Parameters (1) | ||
|---|---|---|
| args | Variant | |
| Returns (1) | ||
| Variant | ||
Starts a solo Test session and yields until that session ends.
The args parameter can be retrieved using
StudioTestService:GetTestArgs(). Returns the value passed to
StudioTestService:EndTest(), or nil if the test ended by other
means.
This method errors if a test session is already running.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
ExecuteRunModeAsync
| Parameters (1) | ||
|---|---|---|
| args | Variant | |
| Returns (1) | ||
| Variant | ||
Starts a Run test session and yields until that session ends.
The args parameter can be retrieved using
StudioTestService:GetTestArgs(). Returns the value passed to
StudioTestService:EndTest(), or nil if the test ended by other
means.
This method errors if a test session is already running.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
GetTestArgs
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| Variant | ||
Returns the argument passed to
StudioTestService:ExecutePlayModeAsync() or
StudioTestService:ExecuteRunModeAsync() for the current test
session, or nil if the session was not started by those methods.
GetTestArgs returns the value as-is, preserving its type. For example,
if the plugin passed a Color3, GetTestArgs returns a Color3.
Note that if you call GetTestArgs a client LocalScript, it may fail.
Server-side calls work as expected.
| Thread safety | Unsafe |
|---|
History 1
- 700 Add GetTestArgs