黄瓜量角器没有运行多个标签

时间:2018-05-26 16:59:35

标签: protractor cucumber cucumberjs

我几乎没有使用@test和@high标记的方案。当我使用以下语法运行单个标记时,它可以正常工作。

的package.json

"smoke": "babel-node node_modules/protractor/bin/protractor protractorConf.js --presets-env --cucumberOpts.tags \"@smoke\"",

但是当我运行它时,为了运行用@test和@high标记的场景,没有任何反应,并且调用了0个场景。

的package.json

"high": "babel-node node_modules/protractor/bin/protractor protractorConf.js --presets-env --cucumberOpts.tags \"@test,@high\""

我尝试了许多选项,如下所示,但没有任何效果。

--cucumberOpts.tags "@test" --cucumberOpts.tags "@high"
--cucumberOpts.tags @test --cucumberOpts.tags @high
--cucumberOpts.tags "(@test and @high)"
--cucumberOpts.tags "@test and @high"

请帮助我了解如何运行多个AND和OR方案。下面是我的包版本。

"cucumber": "^4.2.1",
"protractor": "^5.3.2",
"protractor-cucumber-framework": "^5.0.0"

当我调用命令时,下面是实际输出。

c:\Personal\ATDD  (protractortest@1.0.0)
λ npm run high

> protractortest@1.0.0 high c:\Personal\ATDD
> babel-node node_modules/protractor/bin/protractor protractorConf.js --presets-env --cucumberOpts.tags "@test,@high"

(node:8100) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[11:48:21] I/launcher - Running 1 instances of WebDriver
[11:48:21] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
(node:8100) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.


0 scenarios
0 steps
0m00.000s
Cucumber HTML report c:\Personal\ATDD\reports\html/cucumber_reporter.html generated successfully.
[11:48:25] I/launcher - 0 instance(s) of WebDriver still running
[11:48:25] I/launcher - chrome #01 passed

2 个答案:

答案 0 :(得分:1)

<强>答案

为了解释发生的情况,您希望指定的两个标记都能运行,即使这些方案没有两个标记。

为此,您需要在标记表达式中使用or关键字。

"@test or @high"正是您所寻找的。

有关标记表达式的更多信息

要运行单个标记:

  • --cucumberOpts.tags "@tag1" - 运行标有@ tag1
  • 的方案
  • --cucumberOpts.tags "not @tag1" - 运行未标记为@ tag1
  • 的方案

如果要运行多个标签,或指定不运行的标签:

  • --cucumberOpts.tags "@tag1 or @tag2" - 运行标有@tag1@tag2或两者的方案
  • --cucumberOpts.tags "@tag1 and @tag2" - 运行标有@tag1@tag2
  • 的方案
  • --cucumberOpts.tags "@tag1 not @tag2" - 运行标有@tag1未标记@ tag2的方案

对于更复杂的标记表达式,您可以使用括号来明确,或更改运算符优先级:

  • --cucumberOpts.tags "@tag1 and not (@tag2 or @tag3)" - 运行标记为tag1的方案,其中没有标签@ tag2或@ tag3
  • --cucumberOpts.tags "(not @tag1) and (@tag2 or @tag3)" - 运行未标记为@tag1但已标记为@tag2@tag3或两者
  • 的方案

答案 1 :(得分:0)

我在这里发现了这个问题。实际上,我误解了@test和@high会调用标记为任何一个的场景。我现在知道它会调用一个标有@test&amp; amp; @high就像下面

@smoke @test @high
Scenario: ...
Given ... 
When ...
Then ...

而不喜欢

@smoke @test
Scenario: ...
Given ... 
When ...
Then ...

@smoke @high
Scenario: ...
Given ... 
When ...
Then ...
相关问题