TestService

Mostrar obsoleto

*Este conteúdo é traduzido por IA (Beta) e pode conter erros. Para ver a página em inglês, clique aqui.

Serviço

O TestService é um serviço usado pelo Roblox internamente para executar testes analíticos em seu motor.Torna possível escrever testes sofisticados dentro de um jogo.

Marcos

Scripts que são executados dentro do TestService (via TestService:Run() ) têm acesso a macros especiais que invocam diretamente funções sob o TestService.Macros são essencialmente substituições para grandes blocos de código que não devem precisar ser reescritos cada vez que você quiser chamá-los.

RBX_CHECK

Esta macro faz testes com chamadas para a função TestService:Check() .


<th>Condição de Teste</th>
</tr>
<tr>
<td>RBX_CHECK(cond)</td>
<td>cond == verdadeiro</td>
</tr>
<tr>
<td>RBX_CHECK_MESSAGE(cond, falharMsg)</td>
<td>cond == verdadeiro</td>
</tr>
<tr>
<td>RBX_CHECK_THROW(CÓDIGO)</td>
<td>pcall(function() CÓDIGO terminar/parar/sair) == falso</td>
</tr>
<tr>
<td>RBX_CHECK_NO_THROW(CÓDIGO)</td>
<td>pcall(function() CÓDIGO terminar/parar/sair) == verdadeiro</td>
</tr>
<tr>
<td>RBX_CHECK_EQUAL(a,b)</td>
<td>a == b</td>
</tr>
<tr>
<td>RBX_CHECK_NE(a,b)</td>
<td>a ~= b</td>
</tr>
<tr>
<td>RBX_CHECK_GE(a,b)</td>
<td>a >= b</td>
</tr>
<tr>
<td>RBX_CHECK_LE(a,b)</td>
<td>a <= b</td>
</tr>
<tr>
<td>RBX_CHECK_GT(a,b)</td>
<td>a > b</td>
</tr>
<tr>
<td>RBX_CHECK_LT(a,b)</td>
<td>a < b</td>
</tr>
Microscópio

RBX_REQUIRE

Esta macro faz testes com chamadas para a função TestService:Require() .


<th>Condição de Teste</th>
</tr>
<tr>
<td>RBX_REQUIRE(cond)</td>
<td>cond == verdadeiro</td>
</tr>
<tr>
<td>RBX_REQUIRE_MESSAGE(cond, falharMsg)</td>
<td>cond == verdadeiro</td>
</tr>
<tr>
<td>RBX_REQUIRE_THROW(CÓDIGO)</td>
<td>pcall(function() CÓDIGO terminar/parar/sair) == falso</td>
</tr>
<tr>
<td>RBX_REQUIRE_NO_THROW(CÓDIGO)</td>
<td>pcall(function() CÓDIGO terminar/parar/sair) == verdadeiro</td>
</tr>
<tr>
<td>RBX_REQUIRE_EQUAL(a,b)</td>
<td>a == b</td>
</tr>
<tr>
<td>RBX_REQUIRE_NE(a,b)</td>
<td>a ~= b</td>
</tr>
<tr>
<td>RBX_REQUIRE_GE(a,b)</td>
<td>a >= b</td>
</tr>
<tr>
<td>RBX_REQUIRE_LE(a,b)</td>
<td>a <= b</td>
</tr>
<tr>
<td>RBX_REQUIRE_GT(a,b)</td>
<td>a > b</td>
</tr>
<tr>
<td>RBX_REQUIRE_LT(a,b)</td>
<td>a < b</td>
</tr>
Microscópio

RBX_WARN

Esta macro faz testes com chamadas para a função TestService:Warn() .


<th>Condição de Teste</th>
</tr>
<tr>
<td>RBX_WARN(cond)</td>
<td>cond == verdadeiro</td>
</tr>
<tr>
<td>RBX_WARN_MESSAGE(cond, falhaMsg)</td>
<td>cond == verdadeiro</td>
</tr>
<tr>
<td>RBX_WARN_THROW(CÓDIGO)</td>
<td>pcall(function() CÓDIGO terminar/parar/sair) == falso</td>
</tr>
<tr>
<td>RBX_WARN_NO_THROW(CÓDIGO)</td>
<td>pcall(function() CÓDIGO terminar/parar/sair) == verdadeiro</td>
</tr>
<tr>
<td>RBX_WARN_EQUAL(a,b)</td>
<td>a == b</td>
</tr>
<tr>
<td>RBX_WARN_NE(a,b)</td>
<td>a ~= b</td>
</tr>
<tr>
<td>RBX_WARN_GE(a,b)</td>
<td>a >= b</td>
</tr>
<tr>
<td>RBX_WARN_LE(a,b)</td>
<td>a <= b</td>
</tr>
<tr>
<td>RBX_WARN_GT(a,b)</td>
<td>a > b</td>
</tr>
<tr>
<td>RBX_WARN_LT(a,b)</td>
<td>a < b</td>
</tr>
Microscópio

Macros Adicionais


<th>Descrição</th>
</tr>
<tr>
<td>RBX_ERRO(msg)</td>
<td>Chama diretamente a função <code>Class.TestService:Error()</code>.</td>
</tr>
<tr>
<td>RBX_FAILURE(msg)</td>
<td>Chama diretamente a função <code>Class.TestService:Fail()</code>.</td>
</tr>
<tr>
<td>RBX_MESSAGE(msg)</td>
<td>Chama diretamente a função <code>Class.TestService:Message()</code>.</td>
</tr>
Microscópio

Resumo

Propriedades

  • Ler Parallel

    Se definido como verdadeiro, o jogo começará a funcionar quando o método TestService:Run() do TestService for chamado.

  • Ler Parallel

    Uma descrição do teste sendo executado.

  • Somente leitura
    Não replicado
    Ler Parallel

    Mede quantos erros foram registrados na sessão de teste.

  • Quando definido como verdadeiro, o TestService será executado ao usar a ação Executar na Roblox Studio.

  • Define se o ambiente de física deve ou não ser limitado durante a execução deste teste.

  • Define se objetos físicos poderão ou não dormir enquanto a simulação de teste estiver em andamento.

  • O número de jogadores esperados neste teste, se algum.

  • Define uma quantidade específica de latência adicional experimentada pelos jogadores durante a sessão de teste.

  • Somente leitura
    Não replicado
    Ler Parallel

    Mede quantas chamadas de teste foram registradas na sessão de teste.

  • Define se o teste deve ser limitado para simular o tempo de acordo com o tempo do mundo real ou o mais rápido possível.

  • Ler Parallel

    A quantidade máxima de tempo que os testes são permitidos para executar.

  • Somente leitura
    Não replicado
    Ler Parallel

    Medições de quantas chamadas de aviso foram registradas na sessão de teste.

Métodos

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

    Imprime o resultado da condição para a saída.

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

    Imprime "Test checkpoint: ", seguido por texto, para a saída, em texto azul.

  • Done():()

    Impressões de teste feitas para a saída, em texto azul.

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

    Imprime uma mensagem vermelha para a saída, prefixada por TestService: .

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

    Indica um erro fatal em uma executardo TestService.Se isso for chamado dentro de um script executando dentro do TestService, isso iniciará um ponto de interrupção na linha que invocou o erro.

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

    Imprime a mensagem de teste, seguida por texto para a saída, em texto azul.

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

    Imprime se uma condição é verdadeira junto com o texto de descrição.

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

    Imprime se uma condição for verdadeira, caso contrário, imprime um aviso.

  • Run():()
    Rendimentos
    Segurança do plugin

    Executa scripts que são parentados ao TestService.

Eventos

Propriedades

AutoRuns

Ler Parallel

Description

Ler Parallel

ErrorCount

Somente leitura
Não replicado
Ler Parallel

ExecuteWithStudioRun

Ler Parallel

IsPhysicsEnvironmentalThrottled

Ler Parallel

IsSleepAllowed

Ler Parallel

NumberOfPlayers

Ler Parallel

SimulateSecondsLag

Ler Parallel

TestCount

Somente leitura
Não replicado
Ler Parallel

ThrottlePhysicsToRealtime

Ler Parallel

Timeout

Ler Parallel

WarnCount

Somente leitura
Não replicado
Ler Parallel

Métodos

Check

()

Parâmetros

condition: boolean
Valor Padrão: ""
description: string
Valor Padrão: ""
source: Instance
Valor Padrão: "nil"
line: number
Valor Padrão: 0

Devolução

()

Amostras de código

TestService:Check

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

Checkpoint

()

Parâmetros

text: string
Valor Padrão: ""
source: Instance
Valor Padrão: "nil"
line: number
Valor Padrão: 0

Devolução

()

Amostras de código

Serviço de Teste: Checkpoint

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

Done

()

Devolução

()

Amostras de código

TestService:Done

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

Error

()

Parâmetros

description: string
Valor Padrão: ""
source: Instance
Valor Padrão: "nil"
line: number
Valor Padrão: 0

Devolução

()

Amostras de código

TestService:Error

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

Fail

()

Parâmetros

description: string
Valor Padrão: ""
source: Instance
Valor Padrão: "nil"
line: number
Valor Padrão: 0

Devolução

()

Message

()

Parâmetros

text: string
Valor Padrão: ""
source: Instance
Valor Padrão: "nil"
line: number
Valor Padrão: 0

Devolução

()

Amostras de código

TestService:Message

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

Require

()

Parâmetros

condition: boolean
Valor Padrão: ""
description: string
Valor Padrão: ""
source: Instance
Valor Padrão: "nil"
line: number
Valor Padrão: 0

Devolução

()

Amostras de código

TestService:Require

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

ScopeTime


Devolução

Warn

()

Parâmetros

condition: boolean
Valor Padrão: ""
description: string
Valor Padrão: ""
source: Instance
Valor Padrão: "nil"
line: number
Valor Padrão: 0

Devolução

()

Amostras de código

TestService:Warn

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

isFeatureEnabled

Parâmetros

name: string
Valor Padrão: ""

Devolução

Run

()
Rendimentos
Segurança do plugin

Devolução

()

Eventos

ServerCollectConditionalResult

Parâmetros

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

ServerCollectResult

Parâmetros

text: string
script: Instance
line: number