简体   繁体   English

没有例子的场景大纲 - 黄瓜

[英]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.

相关问题 Java-黄瓜方案大纲中的随机化示例 - Java - Randomising Examples in Cucumber Scenario Outline 未使用黄瓜方案大纲示例的参数 - Cucumber scenario outline examples' parameters not being used Cucumber:场景大纲重用示例表 - Cucumber: Scenario Outline reusing examples table 方案大纲中带有多个示例表的黄瓜标记 - Cucumber Tagging with Multiple Examples tables in a Scenario Outline 带有示例的黄瓜方案大纲:无法创建方案运行器 - Cucumber scenario outline with examples: Failed to create scenario runner 在Cucumber Java中为场景大纲示例运行一次背景 - Running background once for scenario outline examples in Cucumber Java 如何在不使用方案大纲的情况下多次运行黄瓜方案 - How to run cucumber scenario multiple time without using Scenario Outline 黄瓜迁移场景到场景大纲 - Cucumber migrate scenario to scenario outline 如何在黄瓜中不使用大纲的情况下多次运行同一场景? - How to run same scenario multiple times without using outline in Cucumber? 在“场景大纲”行中使用 Cucumber 示例数据,而不是在一个步骤中,不读取数据并且将列标记为未使用 - Using Cucumber examples data in "scenario outline" line, not in a step, data isn't read and column marked as unused
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM