TestService

사용되지 않는 항목 표시
서비스

The TestService is a service used by Roblox internally to run analytical tests on their engine. It makes it possible to write sophisticated tests right inside a game.

Macros

Scripts that are executed inside of the TestService (via TestService:Run()) have access to special macros that directly invoke functions under the TestService. 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.

MacroTest Condition
RBX_CHECK(cond)cond == true
RBX_CHECK_MESSAGE(cond, failMsg)cond == true
RBX_CHECK_THROW(CODE)pcall(function () CODE end) == false
RBX_CHECK_NO_THROW(CODE)pcall(function () CODE end) == true
RBX_CHECK_EQUAL(a,b)a == b
RBX_CHECK_NE(a,b)a ~= b
RBX_CHECK_GE(a,b)a >= b
RBX_CHECK_LE(a,b)a <= b
RBX_CHECK_GT(a,b)a > b
RBX_CHECK_LT(a,b)a < b

RBX_REQUIRE

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

MacroTest Condition
RBX_REQUIRE(cond)cond == true
RBX_REQUIRE_MESSAGE(cond, failMsg)cond == true
RBX_REQUIRE_THROW(CODE)pcall(function () CODE end) == false
RBX_REQUIRE_NO_THROW(CODE)pcall(function () CODE end) == true
RBX_REQUIRE_EQUAL(a,b)a == b
RBX_REQUIRE_NE(a,b)a ~= b
RBX_REQUIRE_GE(a,b)a >= b
RBX_REQUIRE_LE(a,b)a <= b
RBX_REQUIRE_GT(a,b)a > b
RBX_REQUIRE_LT(a,b)a < b

RBX_WARN

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

MacroTest Condition
RBX_WARN(cond)cond == true
RBX_WARN_MESSAGE(cond, failMsg)cond == true
RBX_WARN_THROW(CODE)pcall(function () CODE end) == false
RBX_WARN_NO_THROW(CODE)pcall(function () CODE end) == true
RBX_WARN_EQUAL(a,b)a == b
RBX_WARN_NE(a,b)a ~= b
RBX_WARN_GE(a,b)a >= b
RBX_WARN_LE(a,b)a <= b
RBX_WARN_GT(a,b)a > b
RBX_WARN_LT(a,b)a < b

Additional Macros

MacroDescription
RBX_ERROR(msg)Directly calls the TestService:Error() function.
RBX_FAIL(msg)Directly calls the TestService:Fail() function.
RBX_MESSAGE(msg)Directly calls the TestService:Message() function.

요약

속성

  • 병렬 읽기

    If set to true, the game will start running when the TestService's TestService:Run() method is called.

  • 병렬 읽기

    A description of the test being executed.

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    Measures how many errors have been recorded in the test session.

  • When set to true, the TestService will be executed when using the Run action in Roblox Studio.

  • 숨김
    복제되지 않음
    병렬 읽기

    Sets whether or not the physics engine should be throttled to 30 FPS while the test is being ran.

  • 숨김
    복제되지 않음
    병렬 읽기

    Sets whether or not the physics environment should be throttled while running this test.

  • 병렬 읽기

    Sets whether or not physics objects will be allowed to fall asleep while the test simulation is running.

  • 병렬 읽기

    The number of players expected in this test, if any.

  • Sets a specific amount of additional latency experienced by players during the test session.

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    Measures how many test calls have been recorded in the test session.

  • 병렬 읽기

    The maximum amount of time that tests are allowed to run for.

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    Measures how many warning calls have been recorded in the test session.

메서드

  • Check(condition : bool,description : string,source : Instance,line : number):void

    Prints result of condition to output.

  • Checkpoint(text : string,source : Instance,line : number):void

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

  • Done():void

    Prints Testing Done to the output, in blue text.

  • Error(description : string,source : Instance,line : number):void

    Prints a red message to the output, prefixed by TestService: .

  • Fail(description : string,source : Instance,line : number):void

    Indicates a fatal error in a TestService run. If this is called inside of a script running inside of the TestService, this will initiate a breakpoint on the line that invoked the error.

  • Message(text : string,source : Instance,line : number):void

    Prints Test message, followed by text to the output, in blue text.

  • Require(condition : bool,description : string,source : Instance,line : number):void

    Prints whether a condition is true along with description text.

  • Warn(condition : bool,description : string,source : Instance,line : number):void

    Prints if a condition is true, otherwise prints a warning.

  • Run():void
    생성
    플러그인 보안

    Runs scripts which are parented to TestService.

이벤트

속성

AutoRuns

병렬 읽기

If set to true, the game will start running when the TestService's TestService:Run() method is called.

Description

병렬 읽기

A description of the test being executed.

ErrorCount

읽기 전용
복제되지 않음
병렬 읽기

Measures how many errors have been recorded in the test session.

ExecuteWithStudioRun

병렬 읽기

When set to true, the TestService will be executed when using the Run action in Roblox Studio.

Note:

  • If the TestService.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 at most), or else your computer's CPU will get overloaded.

Is30FpsThrottleEnabled

숨김
복제되지 않음
병렬 읽기

Sets whether or not the physics engine should be throttled to 30 FPS while the test is being ran.

IsPhysicsEnvironmentalThrottled

숨김
복제되지 않음
병렬 읽기

Sets whether or not the physics environment should be throttled while running this test.

IsSleepAllowed

병렬 읽기

Sets whether or not physics objects will be allowed to fall asleep while the test simulation is running.

NumberOfPlayers

병렬 읽기

The number of players expected in this test, if any.

SimulateSecondsLag

병렬 읽기

Sets a specific amount of additional latency experienced by players during the test session.

TestCount

읽기 전용
복제되지 않음
병렬 읽기

Measures how many test calls have been recorded in the test session.

Timeout

병렬 읽기

The maximum amount of time that tests are allowed to run for.

WarnCount

읽기 전용
복제되지 않음
병렬 읽기

Measures how many warning calls have been recorded in the test session.

메서드

Check

void

If condition is true, prints "Check passed: ", followed by description to the output, in blue text. Otherwise, prints "Check failed: ", again, followed by description, but in red text.

매개 변수

condition: bool
description: string
source: Instance
기본값: "nil"
line: number
기본값: 0

반환

void

코드 샘플

TestService:Check

local TestService = game:GetService("TestService")
TestService:Check(false, "example")

Checkpoint

void

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

매개 변수

text: string
source: Instance
기본값: "nil"
line: number
기본값: 0

반환

void

코드 샘플

TestService:Checkpoint

local TestService = game:GetService("TestService")
TestService:Checkpoint("example")

Done

void

Prints Testing Done to the output, in blue text.


반환

void

코드 샘플

TestService:Done

local TestService = game:GetService("TestService")
TestService:Done()

Error

void

Prints a red message to the output, prefixed by TestService: .

매개 변수

description: string
source: Instance
기본값: "nil"
line: number
기본값: 0

반환

void

코드 샘플

TestService:Error

local TestService = game:GetService("TestService")
TestService:Error("this is an error")

Fail

void

Indicates a fatal error in a TestService run. If this is called inside of a script running inside of the TestService, this will initiate a breakpoint on the line that invoked the error.

매개 변수

description: string
source: Instance
기본값: "nil"
line: number
기본값: 0

반환

void

Message

void

Prints Test message, followed by text to the output, in blue text.

매개 변수

text: string
source: Instance
기본값: "nil"
line: number
기본값: 0

반환

void

코드 샘플

TestService:Message

local TestService = game:GetService("TestService")
TestService:Message("example")

Require

void

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, to the output in red text.

매개 변수

condition: bool
description: string
source: Instance
기본값: "nil"
line: number
기본값: 0

반환

void

코드 샘플

TestService:Require

local TestService = game:GetService("TestService")
TestService:Require(false, "example")

ScopeTime


반환

Warn

void

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.

매개 변수

condition: bool
description: string
source: Instance
기본값: "nil"
line: number
기본값: 0

반환

void

코드 샘플

TestService:Warn

local TestService = game:GetService("TestService")
TestService:Warn(false, "this action is invalid")

isFeatureEnabled

매개 변수

name: string

반환

Run

void
생성
플러그인 보안

Runs scripts which are parented to TestService.


반환

void

이벤트

ServerCollectConditionalResult

Fired when the server should collect a conditional test result.

매개 변수

condition: bool
text: string
script: Instance
line: number

ServerCollectResult

Fired when the server should collect a test result.

매개 변수

text: string
script: Instance
line: number