[英]Scenario Outline without examples - Cucumber
Does Scenrio outline
works without Examples
and just a table in every tool or Intellij is the special one? Scenrio outline
是否可以在没有Examples
情况下工作,并且每个工具中都只有一个表格,还是 Intellij 是特殊的?
I read the Gherkin reference and it specifies that a Scenario outline must have an Examples
below it.我阅读了 Gherkin 参考,它指定
Scenario outline must have an Examples
下面Scenario outline must have an Examples
。
https://docs.cucumber.io/gherkin/reference/
But when I run my tests using Scenario Outline
it works fine without the Examples
section anywhere.但是当我使用
Scenario Outline
运行我的测试时,它在没有Examples
部分的任何地方都可以正常工作。 Here:这里:
Scenario Outline: Sequence of customer update for something
Given we create a Customer
When we update the customer with a state "<name>"
Then the response status code is 200
And we close the response
| name|
| Bob|
| Adam|
| Rachel|
How is that working?这是如何运作的?
I think it's interpreting the table as a Cucumber Data Table , which looks similar to an Example table but behaves differently.我认为它将表解释为Cucumber Data Table ,它看起来类似于示例表,但行为不同。 Example tables cause the entire scenario to re-run for each row, but Data Tables are just a large, single parameter passed into the step immediately above them.
示例表会导致对每一行重新运行整个场景,但数据表只是传递到它们上面的步骤中的一个大的单个参数。
I am a little surprised that you didn't get a syntax error for omitting the Examples:
keyword though.我有点惊讶你没有因为省略 Example
Examples:
关键字而出现语法错误。 I just tried removing the Examples:
on one of the Scenario Outlines in my environment, and while it did "pass" (or rather, didn't fail), it didn't actually run the test (the report shows 0 scenarios, 0 steps).我只是尝试删除
Examples:
在我环境中的场景大纲之一上,虽然它确实“通过”(或者更确切地说,没有失败),但它实际上并没有运行测试(报告显示 0 个场景,0 个场景)脚步)。 So beware, you may have a false positive on your hands.所以要小心,你手上可能有误报。
I went to file a bug actually, and found that it has already been filed .其实我去归档了一个bug,发现已经归档了。 Ten years ago...
十年前...
In my case I falsely had a Scenario Outline without examples at all:就我而言,我错误地有一个完全没有示例的场景大纲:
Scenario Outline: System displays search criteria
Given UserS is logged in
Then UserS is on the 'Search' page
When UserS clicks on the 'Search criteria' link
Then the system displays the search criteria
Tests weirdly run all the way completing without errors.测试奇怪地一直运行,没有错误。 It was only when I tried to create an html report that a bug kept saying that examples did not exist, which led us to check the feature file.
只是当我尝试创建一个 html 报告时,一个错误一直说示例不存在,这导致我们检查功能文件。
So my guess is the tests somehow bypass the Examples section, if there is no parameter present, but the reporter is not that lenient.所以我的猜测是,如果没有参数存在,测试会以某种方式绕过示例部分,但报告者并不那么宽容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.