Service allowing plugins to automate and customize Test and Run mode testing.
Its interface does not cross the network boundary.
Instances of this class cannot be created with Instance.new.
It is a singleton that may be acquired with GetService.
Tags: [NotCreatable, Service, NotReplicated]
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:
1
2
3
4
5
| --Plugin Script
local StudioTestService = game:GetService("StudioTestService")
local testResult = StudioTestService:ExecuteRunModeAsync("MyTestSuite")
print("Test finished. Result:", testResult)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| --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
|
| Parameters (1) |
|---|
| numPlayers | int |
| Returns (1) |
|---|
| null |
History 1
| Parameters (0) |
|---|
| No parameters. |
| Returns (1) |
|---|
| bool |
History 1
ExecuteMultiplayerTestAsync
It will block the calling thread until completion.
History 1
Tags: [Yields]
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.
It will block the calling thread until completion.
History 1
Tags: [Yields]
It will block the calling thread until completion.
History 1
Tags: [Yields]
| Parameters (0) |
|---|
| No parameters. |
| Returns (1) |
|---|
| Variant |
History 1
| Parameters (0) |
|---|
| No parameters. |
| Returns (1) |
|---|
| null |
History 1