尝试使用“示例”时解析问题黄瓜功能部分
运气不佳
谷歌搜索此错误消息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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
替换
为
Replace
with
当您的测试扩展到包含示例时,您应该始终使用
场景大纲
。场景
适用于那些需要输入不超过一个数据进行测试的测试。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.