跳至主要内容

TestResult

单个TestCase运行的结果。


属性

附件

Added in: v1.10 testResult.attachments

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

用法

testResult.attachments

类型

  • 数组<Object>
    • name string

      附件名称。

    • contentType string

      此附件的内容类型,用于在报告中正确显示,例如'application/json''image/png'

    • path string (可选)

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

    • body Buffer (可选)

      可选的附件内容,用于替代文件。


持续时间

Added in: v1.10 testResult.duration

运行时间(毫秒)。

用法

testResult.duration

类型


错误

Added in: v1.10 testResult.error

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

用法

testResult.error

类型


错误

Added in: v1.10 testResult.errors

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

用法

testResult.errors

类型


parallelIndex

Added in: v1.30 testResult.parallelIndex

工作线程的索引值介于0workers - 1之间。可以确保同时运行的工作线程具有不同的parallelIndex

用法

testResult.parallelIndex

类型


重试

Added in: v1.10 testResult.retry

当测试多次重试时,每次重试尝试都会分配一个顺序编号。

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

用法

testResult.retry

类型


开始时间

Added in: v1.10 testResult.startTime

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

用法

testResult.startTime

类型


状态

Added in: v1.10 testResult.status

该测试结果的状态。另请参阅testCase.expectedStatus

用法

testResult.status

类型

  • "passed" | "failed" | "timedOut" | "skipped" | "interrupted"

标准错误输出

Added in: v1.10 testResult.stderr

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

用法

testResult.stderr

类型


标准输出

Added in: v1.10 testResult.stdout

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

用法

testResult.stdout

类型


步骤

Added in: v1.10 testResult.steps

本次测试运行中的步骤列表。

用法

testResult.steps

类型


workerIndex

Added in: v1.10 testResult.workerIndex

运行测试的工作线程索引。如果测试一次都没有运行过,例如当用户中断测试时,唯一的结果将具有等于-1workerIndex

了解更多关于使用Playwright Test进行并行测试和分片的信息。

用法

testResult.workerIndex

类型