【问题标题】:Data Driven testing with cucumber protractor使用黄瓜量角器进行数据驱动测试
【发布时间】:2019-03-28 00:58:53
【问题描述】:

假设我的 demo.feature 文件中有一个场景

Scenario Outline: Gather and load all submenus
Given I will login using <username> and <password>
When I will click all links
Examples :
| username | password |
| user1 | pass1 |
| use2 | pass2 |

假设我有一个名为 users.json 的文件

如何从该外部文件中获取这些用户名和密码到我的 demo.feature ? 我可以通过将参数传递给我的 npm 脚本来捕获文件,如下所示? npm run cucumber -- --params.environment.file=usernames.json

【问题讨论】:

    标签: protractor cucumber gherkin cucumberjs


    【解决方案1】:

    我建议让登录步骤在步骤定义中访问该 json 文件。只需确保不要将其签入存储库,而是始终期望它位于某个位置,但仅在本地而不是存储库中。

    出于以下几个原因,执行上述操作很有用: - 运行测试的工程师不需要知道必须从命令行传入参数 - 该代码在该步骤中是关于它如何登录的自我描述 - 您可以添加更好的错误处理 - 如果需要,您可以使用多个用户文件,方法是让钩子根据标签定义路径等

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-02
      • 1970-01-01
      • 1970-01-01
      • 2014-10-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多