Skip to main content

Suite

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

  • 根套件为每个 FullProject 创建了一个子套件。
    • 项目套件 #1。每个项目测试文件都有一个子套件。
      • 文件套件 #1
        • [测试用例] #1
        • [测试用例] #2
        • 对应于 test.describe() 组的套件
          • [测试用例] #1 在一个组里
          • [测试用例] #2 在一个组里
        • < more test cases ... >
      • 文件套件 #2
      • < more file suites ... >
    • 项目套件#2
    • < more project suites ... >

reporter.onBegin() 方法中,Reporter 会被分配一个根套件。

🌐 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.

用法

suite.allTests();

返回


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.

用法

suite.entries();

返回


project

Added in: v1.10 suite.project

此套件所属项目的配置,或对于根套件使用 void

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

用法

suite.project();

返回


titlePath

Added in: v1.10 suite.titlePath

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

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

用法

suite.titlePath();

返回


属性

🌐 Properties

location

Added in: v1.10 suite.location

套件定义在源中的位置。根套件和项目套件没有此信息。

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

用法

suite.location

类型


parent

Added in: v1.10 suite.parent

父套件,根套件缺失。

🌐 Parent suite, missing for the root suite.

用法

suite.parent

类型


suites

Added in: v1.10 suite.suites

子套件。有关套件的层级结构,请参见 Suite

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

用法

suite.suites

类型

  • [数组]<[套件]>

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.

用法

suite.tests

类型

  • [数组]<[测试用例]>

title

Added in: v1.10 suite.title

套件标题。

🌐 Suite title.

  • 根套件为空。
  • 项目套件的项目名称。
  • 文件套件的文件路径。
  • 标题传递给test.describe()用于一个分组套件。

用法

suite.title

类型


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.

用法

suite.type

类型

  • "根" | "项目" | "文件" | "描述"