我正在尝试运行一些使用Scenario Outlines
在specflow中编写的测试,其中我有输入和输出参数化,这很好,我可以做到。
然而,我还希望在多个浏览器中重复所有测试。
这意味着有一组参数用于定义测试场景,另一组用于迭代环境设置的所有不同变体(浏览器类型)
作为我想要做的一个简单示例我有一个网页上有链接,每个链接都是基于广告组成员资格授权的(网站是使用Windows身份验证的内部网)所以我有测试:
Scenario Outline: Only authorised users can click through links on main page
Given a user <name> in domain "ad" with password <password>
And the home page is loaded
When I click the link <link>
Then the page has "title" <title>
Scenarios:
| name | password | link | title |
| user1 | VMoney123 | "link1" | "You are not authorized to see this section" |
| user2 | VMoney123 | "link1" | "Success" |
| user2 | VMoney123 | "link2" | "Success" |
但是,当我天真地尝试添加Examples
来迭代浏览器风格时:
Scenario Outline: Only authorised users can click through links on main page
Given a user <name> in domain "ad" with password <password>
And a <browser> browser
And the home page is loaded
When I click the link <link>
Then the page has "title" <title>
Examples:
| browser |
| "chrome" |
| "ie" |
Scenarios:
| name | password | link | title |
| name | password | link | title |
| user1 | VMoney123 | "link1" | "You are not authorized to see this section" |
| user2 | VMoney123 | "link1" | "Success" |
| user2 | VMoney123 | "link2" | "Success" |
并且构建错误:
CS1029 #error: 'Generation error: The example sets must provide the same parameters.'
显然我可以通过6个场景(或示例)来做到这一点,但是如果我需要将其扩展到另外5个浏览器,这意味着额外的15个场景,它很快变得不合适,肯定有办法......
答案 0 :(得分:0)
您的功能无效Gherkin。在这里查看它的参考:https://cucumber.io/docs/reference
要为不同的浏览器运行相同的方案,请查看此示例:
https://github.com/techtalk/SpecFlow.Plus.Examples/tree/master/SeleniumWebTest
它使用SpecFlow + Runner来实现不同浏览器的支持。
完全披露:我是SpecFlow和SpecFlow +的开发人员。