带有浏览器测试的标记功能(Cucumber JUnit 平台引擎)

Tag feature with browser tests (Cucumber JUnit Platform Engine)

我有几个 API 测试和浏览器测试。浏览器测试必须 运行 一致。 该文档 (https://github.com/cucumber/cucumber-jvm/tree/main/junit-platform-engine) 说:

  1. 首先,我需要 运行 使用以下参数并行进行所有测试:
cucumber.execution.parallel.enabled=true
cucumber.execution.parallel.config.strategy=fixed
cucumber.execution.parallel.config.fixed.parallelism=4
  1. 然后我需要标记资源,访问将是一致的(读写,或只读)。例如,资源 SYSTEM_PROPERTIES:
cucumber.execution.exclusive-resources.reads-and-writes-system-properties.read-write=SYSTEM_PROPERTIES

但是,如何指定我的浏览器测试而不是此资源?

如果您的独占资源是浏览器,您会在心里为它保留字符串 BROWSER。为资源命名并不重要,重要的是它可以唯一标识浏览器。

然后你决定哪个 Cucumber 标签匹配这个资源,比如 @browser。然后从标记中删除 @ 并将其余部分放入属性文件中:

cucumber.execution.exclusive-resources.browser.read-write=BROWSER

然后你用 @browser 标记你的场景:

Feature: Exclusive resources

 @browser
 Scenario: first example
   Given this scenario uses the browser

 @browser
 Scenario: second example
   Given this scenario uses the browser

您还可以通过标记特征来标记特征中的所有场景

@browser
Feature: Exclusive resources

 Scenario: first example
   Given this scenario uses the browser

 Scenario: second example
   Given this scenario uses the browser