Suite
Suite
是一个测试组。 Playwright Test 中的所有测试都形成以下层次结构
- 根套件为每个 FullProject 都有一个子套件。
- 项目套件 #1。为项目中的每个测试文件都有一个子套件。
- 文件套件 #1
- TestCase #1
- TestCase #2
- 与 test.describe() 组对应的套件
- < 更多测试用例 ... >
- 文件套件 #2
- < 更多文件套件 ... >
- 文件套件 #1
- 项目套件 #2
- < 更多项目套件 ... >
- 项目套件 #1。为项目中的每个测试文件都有一个子套件。
在 reporter.onBegin() 方法中,为 Reporter 提供了根套件。
方法
allTests
添加于:v1.10返回此套件及其后代中所有测试用例的列表,与 suite.tests 相反。
用法
suite.allTests();
返回值
entries
添加于:v1.44直接在此套件中定义的测试用例和套件。元素按照声明顺序返回。您可以使用 testCase.type 和 suite.type 来区分各种条目类型。
用法
suite.entries();
返回值
project
添加于:v1.10此套件所属项目的配置,或者对于根套件,则为 void。
用法
suite.project();
返回值
- FullProject | [undefined]#
titlePath
添加于:v1.10返回从根目录到此套件的标题列表。
用法
suite.titlePath();
返回值
属性
location
添加于:v1.10套件在源文件中定义的位置。根套件和项目套件中缺失。
用法
suite.location
类型
parent
添加于:v1.10父套件,根套件中缺失。
用法
suite.parent
类型
suites
添加于:v1.10子套件。请参阅 Suite 了解套件的层次结构。
用法
suite.suites
类型
tests
添加于:v1.10套件中的测试用例。请注意,列表中仅包含直接在此套件中定义的测试用例。在嵌套的 test.describe() 组中定义的任何测试用例都列在子套件 suite.suites 中。
用法
suite.tests
类型
title
添加于:v1.10套件标题。
- 根套件为空。
- 项目套件的项目名称。
- 文件套件的文件路径。
- 传递给 test.describe() 的标题,用于组套件。
用法
suite.title
类型
type
添加于:v1.44返回套件的类型。套件形成以下层次结构:root
-> project
-> file
-> describe
-> ...describe
-> test
。
用法
suite.type
类型
- "root" | "project" | "file" | "describe"