尝试使用“示例”时解析问题黄瓜功能部分

发布于 2024-09-12 18:28:49 字数 1015 浏览 2 评论 0原文

运气不佳

谷歌搜索此错误消息features/manage_hand_evaluator.feature: Parse error at features/manage_hand_evaluator.feature:21 时 。在期望以下之一时找到示例:comment、py_string、row、scenario、scenario_outline、step、tag。 (当前状态:步骤)。 (Gherkin::Parser::ParseError)

这是我对示例部分的设置(目前没有其他场景,只有“功能:”部分之后的这个场景)

...

Scenario: Evaluating for current straights
  Given I am a player with <hand>
  When the board is <board>
  Then the current possible straights should be <possibles>

  Examples:
    | board | hand |    possibles                  | 
    | A23   | 45   | A2345                         | 
    | 3456  | 23   | A2345,23456,34567,45678       | 
    | 789T  | A2   | 56789,6789T,789TJ,89TJQ       | 
    | 45678 | 23   | 23456,34567,45678,56789,6789T | 

我还已经为以下设置了步骤定义那些“给定,何时,然后”行(当我用一些文本替换 , , 并注释掉“示例”部分时,测试顺利通过)。所以看来步骤定义设置正确,只是 .feature 文件中的内容存在某种解析问题,我无法弄清楚我做错了什么。

安装的相关宝石: Gherkin (2.1.5)(尝试过 2.2.0,但它与我的 Cucumber 版本不同) 黄瓜 (0.8.5) 黄瓜导轨 (0.3.2) 导轨 (2.3.8)

No luck in googling on this error message

features/manage_hand_evaluator.feature: Parse error at features/manage_hand_evaluator.feature:21. Found examples when expecting one of: comment, py_string, row, scenario, scenario_outline, step, tag. (Current state: step). (Gherkin::Parser::ParseError)

Here's the setup I have for Examples section (there are no other Scenarios at this time, just this one after the "Feature:" section)

...

Scenario: Evaluating for current straights
  Given I am a player with <hand>
  When the board is <board>
  Then the current possible straights should be <possibles>

  Examples:
    | board | hand |    possibles                  | 
    | A23   | 45   | A2345                         | 
    | 3456  | 23   | A2345,23456,34567,45678       | 
    | 789T  | A2   | 56789,6789T,789TJ,89TJQ       | 
    | 45678 | 23   | 23456,34567,45678,56789,6789T | 

I also have step definitions set up already for those "Given, When, Then" lines (and tests passes fine when I replace , , with some text and comment out the "Examples" section). So it seems step definitions are set up properly, just that there is some kind of parsing issue with the contents I have in .feature file and I cannot figure out what I am doing wrong.

Relevant gems installed:
Gherkin (2.1.5) (tried 2.2.0 but it breaks with my version of Cucumber)
Cucumber (0.8.5)
Cucumber-Rails (0.3.2)
Rails (2.3.8)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦初启 2024-09-19 18:28:49

替换

Scenario:

Scenario Outline:

Replace

Scenario:

with

Scenario Outline:
阳光的暖冬 2024-09-19 18:28:49

当您的测试扩展到包含示例时,您应该始终使用场景大纲场景适用于那些需要输入不超过一个数据进行测试的测试。

When you have tests that extends to having examples, you should always use Scenario Outline. Scenario is for those kind of tests with not more than one data to be inputted to test.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文