量角器 - 黄瓜背景钩

时间:2016-08-09 16:01:28

标签: cucumber protractor bdd cucumberjs

我们正在使用测试Protractor-Cucumber BDD测试框架。黄瓜js不支持'背景'钩子吗?

我正在尝试如下所示的场景:

Background:
Given an authenticated user

Scenario Outline:  test something
Given the home page is displayed
When I fill the form for <patient>
Then form should be submitted successfully

Examples:
|patient|
|pat1   |
|pat2   |

运行获取错误 -

expected: #TagLine, #ScenarioLine, #ScenarioOutlineLine, #Comment, #Empty, got 'Background:'
expected: #TagLine, #ScenarioLine, #ScenarioOutlineLine, #Comment, #Empty, got 'Given an authenticated user'

2 个答案:

答案 0 :(得分:1)

看起来缺少功能标题。黄瓜需要为您的方案定义一个功能才能运行。

要试一试,请试试这个:

Feature: Test features

Background:
Given an authenticated user

Scenario Outline:  test something
Given the home page is displayed
When I fill the form for <patient>
Then form should be submitted successfully

Examples:
|patient|
|pat1   |
|pat2   |

答案 1 :(得分:0)

使用场景大纲时,步骤定义文件中的示例应该有正则表达式。对于您的情况,在此步骤中,当我为患者填写表格时,对于患者,您需要使用(。*)此正则表达式来执行pat1和pat2示例。

第二种情况,您遇到的任何错误对于两种情况都是不同的。在第一种情况下,您期望这样:#TagLine,#ScenarioLine,#ScenarioOutlineLine,#Comment,#Empty,但是步骤定义文件的结果仅给出了'Background:',这意味着测试用例的断言失败。功能文件中没有错误。如果您正在运行多个测试用例,则需要为此功能命名,以标识我们的测试用例。

谢谢。