Skip to main content

TestResult

单次TestCase运行的结果。

🌐 A result of a single TestCase run.


属性

🌐 Properties

annotations

Added in: v1.52 testResult.annotations

适用于当前测试的注解列表。包括:

🌐 The list of annotations applicable to the current test. Includes:

在测试执行期间,可以通过 testInfo.annotations 获取注释。

🌐 Annotations are available during test execution through testInfo.annotations.

了解有关 测试注释 的更多信息。

🌐 Learn more about test annotations.

用法

testResult.annotations

类型

  • [数组]<[对象]>
    • type string

      注释类型,例如 'skip''fail'

    • description string (optional)

      可选描述。

    • location Location (optional)

      源代码中添加注释的可选位置。


attachments

Added in: v1.10 testResult.attachments

在测试执行期间通过testInfo.attachments附加的文件或缓冲区列表。

🌐 The list of files or buffers attached during the test execution through testInfo.attachments.

用法

testResult.attachments

类型

  • [数组]<[对象]>
    • name string

      附件名称。

    • contentType string

      该附件的内容类型,以便在报告中正确呈现,例如 'application/json''image/png'

    • path string (optional)

      文件系统上附加文件的可选路径。

    • body Buffer (optional)

      使用可选附件正文代替文件。


duration

Added in: v1.10 testResult.duration

运行时间以毫秒为单位。

🌐 Running time in milliseconds.

用法

testResult.duration

类型


error

Added in: v1.10 testResult.error

测试执行期间抛出的第一个错误(如果有的话)。这等于 testResult.errors 中的第一个元素。

🌐 First error thrown during test execution, if any. This is equal to the first element in testResult.errors.

用法

testResult.error

类型


errors

Added in: v1.10 testResult.errors

测试执行期间抛出的错误。

🌐 Errors thrown during the test execution.

用法

testResult.errors

类型

  • [数组]<[测试错误]>

parallelIndex

Added in: v1.30 testResult.parallelIndex

介于 0workers - 1 之间的工作进程索引。保证同时运行的工作进程具有不同的 parallelIndex

🌐 The index of the worker between 0 and workers - 1. It is guaranteed that workers running at the same time have a different parallelIndex.

用法

testResult.parallelIndex

类型


retry

Added in: v1.10 testResult.retry

当测试重试多次时,每次重试都会被赋予一个序列号。

🌐 When test is retried multiple times, each retry attempt is given a sequential number.

了解有关 测试重试 的更多信息。

🌐 Learn more about test retries.

用法

testResult.retry

类型


startTime

Added in: v1.10 testResult.startTime

此特定测试运行的开始时间。

🌐 Start time of this particular test run.

用法

testResult.startTime

类型


status

Added in: v1.10 testResult.status

此测试结果的状态。另请参见 testCase.expectedStatus

🌐 The status of this test result. See also testCase.expectedStatus.

用法

testResult.status

类型

  • "通过" | "未通过" | "超时" | "跳过" | "中断"

stderr

Added in: v1.10 testResult.stderr

在测试运行期间写入标准错误的任何内容。

🌐 Anything written to the standard error during the test run.

用法

testResult.stderr

类型

  • [数组]<[字符串] | [缓冲区]>

stdout

Added in: v1.10 testResult.stdout

在测试运行期间写入标准输出的任何内容。

🌐 Anything written to the standard output during the test run.

用法

testResult.stdout

类型

  • [数组]<[字符串] | [缓冲区]>

steps

Added in: v1.10 testResult.steps

此测试运行中的步骤列表。

🌐 List of steps inside this test run.

用法

testResult.steps

类型

  • [数组]<[测试步骤]>

workerIndex

Added in: v1.10 testResult.workerIndex

测试运行的工作节点索引。如果测试一次都未运行,例如用户中断了测试,则唯一的结果中 workerIndex 将等于 -1

🌐 Index of the worker where the test was run. If the test was not run a single time, for example when the user interrupted testing, the only result will have a workerIndex equal to -1.

通过 Playwright 测试了解更多关于 并行处理和分片 的信息。

🌐 Learn more about parallelism and sharding with Playwright Test.

用法

testResult.workerIndex

类型