黄瓜量角器不是 运行 多个标签
cucumber protractor is not running with multiple tags
我几乎没有用@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
我在这里发现了问题。实际上,我误解了@test 和@high 将调用标有任何一个的场景。我现在知道它会调用一个用@test和@high标记的场景,如下所示
@smoke @test @high
Scenario: ...
Given ...
When ...
Then ...
不喜欢
@smoke @test
Scenario: ...
Given ...
When ...
Then ...
@smoke @high
Scenario: ...
Given ...
When ...
Then ...
回答
为了解释发生了什么,您期望指定的两个标签都是 运行,即使场景中没有这两个标签。
为此,您需要在标记表达式中使用 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
或两者都标记的场景
我几乎没有用@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
我在这里发现了问题。实际上,我误解了@test 和@high 将调用标有任何一个的场景。我现在知道它会调用一个用@test和@high标记的场景,如下所示
@smoke @test @high
Scenario: ...
Given ...
When ...
Then ...
不喜欢
@smoke @test
Scenario: ...
Given ...
When ...
Then ...
@smoke @high
Scenario: ...
Given ...
When ...
Then ...
回答
为了解释发生了什么,您期望指定的两个标签都是 运行,即使场景中没有这两个标签。
为此,您需要在标记表达式中使用 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
或两者都标记的场景