TestResult
单个 TestCase 运行的结果。
属性
annotations
新增于: v1.52适用于当前测试的 annotations 列表。包括
- 通过 test() 和 test.describe() 定义在测试或套件上的 annotations;
- 由方法 test.skip()、test.fixme() 和 test.fail() 隐式添加的 annotations;
- 在测试执行期间添加到 testInfo.annotations 的 annotations。
在测试执行期间,可以通过 testInfo.annotations 访问 annotations。
了解更多关于 测试 annotations 的信息。
用法
testResult.annotations
类型
attachments
新增于: v1.10在测试执行期间通过 testInfo.attachments 附加的文件或 buffer 列表。
用法
testResult.attachments
类型
duration
新增于: v1.10运行时间,单位为毫秒。
用法
testResult.duration
类型
error
新增于: v1.10测试执行期间抛出的第一个错误(如果有)。这等于 testResult.errors 中的第一个元素。
用法
testResult.error
类型
errors
新增于: v1.10测试执行期间抛出的错误列表。
用法
testResult.errors
类型
parallelIndex
新增于: v1.30worker 的索引,范围在 0 和 workers - 1 之间。保证同时运行的 worker 具有不同的 parallelIndex。
用法
testResult.parallelIndex
类型
retry
新增于: v1.10当测试重试多次时,每次重试尝试都会被赋予一个序列号。
了解更多关于 测试重试 的信息。
用法
testResult.retry
类型
startTime
新增于: v1.10本次测试运行的开始时间。
用法
testResult.startTime
类型
status
新增于: v1.10此测试结果的状态。另请参阅 testCase.expectedStatus。
用法
testResult.status
类型
- "通过" | "失败" | "超时" | "跳过" | "中断"
stderr
新增于: v1.10测试运行期间写入标准错误 (stderr) 的所有内容。
用法
testResult.stderr
类型
stdout
新增于: v1.10测试运行期间写入标准输出 (stdout) 的所有内容。
用法
testResult.stdout
类型
steps
新增于: v1.10此测试运行中的步骤列表。
用法
testResult.steps
类型
workerIndex
新增于: v1.10运行测试的 worker 索引。如果测试从未运行过(例如用户中断了测试),则唯一的测试结果的 workerIndex 将等于 -1。
了解更多关于 并行和分片 在 Playwright Test 中的用法。
用法
testResult.workerIndex
类型