Skip to main content

TestRun

控制哪些测试将运行以及它们的预期状态。TestRunreporter.preprocess() 期间可用。安装和拆卸项目无法更改。

🌐 Controls which tests will run and their expected status. A TestRun is available during reporter.preprocess(). Setup and teardown projects cannot be changed.


方法

🌐 Methods

exclude

Added in: v1.62 testRun.exclude

从运行中排除一个测试或测试套件。被排除的测试不会出现在报告中,并且它们的内容不会被执行。

🌐 Excludes a test or suite from the run. Excluded tests do not appear in the report and their bodies are not executed.

用法

testRun.exclude(test);

参数

  • test TestCase | Suite#

    要排除的测试或套件。根套件无法被排除。


fail

Added in: v1.62 testRun.fail

将测试或套件中的每个测试标记为“应该失败”。Playwright 会运行这些测试并确保它们确实失败,这对于在功能修复之前记录损坏的功能很有用。

🌐 Marks a test or every test in a suite as "should fail". Playwright runs the tests and ensures they are actually failing, useful for documenting broken functionality until it is fixed.

用法

testRun.fail(test);
testRun.fail(test, reason);

参数

  • test TestCase | Suite#

    标记为预期失败的测试或测试集。

  • reason string (optional)#

    可选解释以注释描述的形式出现。


fixme

Added in: v1.62 testRun.fixme

将一个测试或测试套件中的所有测试标记为 fixme。测试内容不会被执行,测试会被报告为跳过,目的是为了以后修复它们。

🌐 Marks a test or every test in a suite as fixme. The test bodies are not executed and the tests are reported as skipped, with the intention to fix them.

用法

testRun.fixme(test);
testRun.fixme(test, reason);

参数

  • test TestCase | Suite#

    标记为待修复的测试或套件。

  • reason string (optional)#

    可选解释以注释描述的形式出现。


skip

Added in: v1.62 testRun.skip

跳过一个测试或测试套件中的所有测试。测试内容不会被执行,测试会被标记为已跳过。

🌐 Skips a test or every test in a suite. The test bodies are not executed and the tests are reported as skipped.

用法

testRun.skip(test);
testRun.skip(test, reason);

参数

  • test TestCase | Suite#

    要跳过的测试或套件。

  • reason string (optional)#

    可选解释以注释描述的形式出现。


skipSharding

Added in: v1.62 testRun.skipSharding

禁用 Playwright 内置的分片过滤器,让这次运行的分片由报告器处理。报告器通常会通过在非本分片的测试上调用 testRun.exclude() 来实现自己的分片。

🌐 Disables Playwright's built-in shard filter for this run, leaving sharding to the reporter. Reporters typically implement their own sharding by calling testRun.exclude() on out-of-shard tests.

用法

testRun.skipSharding();