我试图运行一个简单的特征文件,但是我得到了异常:异常in thread "main“cucumber.runtime.CucumberException:解析特征文件时出错。
这是由: gherkin.lexer.LexingError: Lexing错误引起的
我正在尝试参数化一个When语句,并得到了这个异常:
Scenario: Login to Gmail
Given User is on Gmail login page
When User enters <userName> and <pwd>
And Clicks on login button
Then User should redirect to home page
scenario outline(tried Examples as well but didn't worked):
|userName | pwd |
|ravivani10 | abc |发布于 2014-11-12 00:40:23
场景大纲的正确语法是以关键字Scenario Outline:开头,并使用 examples :关键字列出示例。
Scenario Outline: Login to Gmail
Given User is on Gmail login page
When User enters <userName> and <pwd>
And Clicks on login button
Then User should redirect to home page
Examples:
| userName | pwd |
| ravivani10 | abc |发布于 2017-02-17 01:40:32
我也有同样的问题,但是我使用了正确的语法。原来我的格式化是错的,是的,你没看错:格式化。我的场景是这样的:
Scenario Outline: Confirm that hitting the endpoint returns the expected data
Given uri url/to/a/service/to/test/param/{interval} and method GET
And system user
When I call the web service
Then I expect that 'http status is' '200'
And the following rules must apply to the response
| element | expectation | value |
| $ | is not null | |
| objectType | value = | Volume |
| objectData | is not null | |
| objectData | count = | 1 |
| objectData[0].value | is not null | |
| objectData[0].value | data type is | float |
| objectData[0].value | value = | <value> |
Examples:
| interval | value |
| int1 | 355.77 |
| int2 | 332.995 |
| int3 | 353.71125 |以上测试将失败,并显示Lexing错误。现在,看看我的测试中的示例片段的缩进(它在Scenario Ouline中缩进了一层)。
如果我缩进我的测试,如下所示(与Scenario大纲相同级别):
Scenario Outline: Confirm that hitting the endpoint returns the expected data
Given uri url/to/a/service/to/test/param/{interval} and method GET
And system user
When I call the web service
Then I expect that 'http status is' '200'
And the following rules must apply to the response
| element | expectation | value |
| $ | is not null | |
| objectType | value = | Volume |
| objectData | is not null | |
| objectData | count = | 1 |
| objectData[0].value | is not null | |
| objectData[0].value | data type is | float |
| objectData[0].value | value = | <value> |
Examples:
| interval | value |
| int1 | 355.77 |
| int2 | 332.995 |
| int3 | 353.71125 |以上测试将通过。对我来说太傻了,但这就是它的工作原理。
发布于 2017-04-11 23:23:21
这可能是由于在每行数据的末尾没有最终的|造成的。这不是行动的原因,但可能会对其他人有所帮助。
https://stackoverflow.com/questions/26864021
复制相似问题