Skip to main content

Suite

Suite 是一组测试。Playwright Test 中的所有测试均形成以下层次结构:

¥Suite is a group of tests. All tests in Playwright Test form the following hierarchy:

< 更多测试用例 ... >

  • 文件套件 #2

    ¥File suite #2

< 更多文件套件 ... >

  • 项目套件#2

    ¥Project suite #2

< 更多项目套件 ... >

报告器在 reporter.onBegin() 方法中得到了一个根套件。

¥Reporter is given a root suite in the reporter.onBegin() method.


方法

¥Methods

allTests

Added in: v1.10 suite.allTests

返回该套件及其后代中所有测试用例的列表,与 suite.tests 相反。

¥Returns the list of all test cases in this suite and its descendants, as opposite to suite.tests.

用法

¥Usage

suite.allTests();

返回

¥Returns


entries

Added in: v1.44 suite.entries

直接在此套件中定义的测试用例和套件。元素按其声明顺序返回。你可以使用 testCase.typesuite.type 区分各种条目类型。

¥Test cases and suites defined directly in this suite. The elements are returned in their declaration order. You can differentiate between various entry types by using testCase.type and suite.type.

用法

¥Usage

suite.entries();

返回

¥Returns


project

Added in: v1.10 suite.project

该套件所属项目的配置,或根套件的 void

¥Configuration of the project this suite belongs to, or void for the root suite.

用法

¥Usage

suite.project();

返回

¥Returns


titlePath

Added in: v1.10 suite.titlePath

返回从根到该套件的标题列表。

¥Returns a list of titles from the root down to this suite.

用法

¥Usage

suite.titlePath();

返回

¥Returns


属性

¥Properties

location

Added in: v1.10 suite.location

定义套件的源中的位置。缺少根套件和项目套件。

¥Location in the source where the suite is defined. Missing for root and project suites.

用法

¥Usage

suite.location

类型

¥Type


parent

Added in: v1.10 suite.parent

父套件,根套件缺失。

¥Parent suite, missing for the root suite.

用法

¥Usage

suite.parent

类型

¥Type


suites

Added in: v1.10 suite.suites

子套件。请参阅 Suite 了解套件的层次结构。

¥Child suites. See Suite for the hierarchy of suites.

用法

¥Usage

suite.suites

类型

¥Type


tests

Added in: v1.10 suite.tests

套件中的测试用例。请注意,列表中只有直接在该套件中定义的测试用例。嵌套 test.describe() 组中定义的任何测试用例都列在子 suite.suites 中。

¥Test cases in the suite. Note that only test cases defined directly in this suite are in the list. Any test cases defined in nested test.describe() groups are listed in the child suite.suites.

用法

¥Usage

suite.tests

类型

¥Type


title

Added in: v1.10 suite.title

套件标题。

¥Suite title.

  • 根套件为空。

    ¥Empty for root suite.

  • 项目套件的项目名称。

    ¥Project name for project suite.

  • 文件套件的文件路径。

    ¥File path for file suite.

  • 群组套件的所有权已移交给 test.describe()

    ¥Title passed to test.describe() for a group suite.

用法

¥Usage

suite.title

类型

¥Type


type

Added in: v1.44 suite.type

返回套件的类型。套件形成以下层次结构:root -> project -> file -> describe -> ...describe -> test.

¥Returns the type of the suite. The Suites form the following hierarchy: root -> project -> file -> describe -> ...describe -> test.

用法

¥Usage

suite.type

类型

¥Type

  • "root" | "project" | "file" | "describe"