如何在多个场景或功能文件中重复使用黄瓜测试数据? 我想绕过表数据代码重复。
我当前的专题文件:
Scenario: At begining unable to click on first
When On Sidebar page I click element basic table pagination
And On PaginationTable page I click element first
Then On PaginationTable page label pagination info value is Showing 1 to 13 of 1497 rows
And I check table result pagination for PaginationTable page
|noId|first_name|last_name|email|
|1|Abbba|Baaba|big0@data.com|
|2|Left|Right|big1@data.com|
And I close and log out
Scenario: At begining unable to click on left
When On Sidebar page I click element basic table pagination
And On PaginationTable page I click element left
Then On PaginationTable page label pagination info value is Showing 1 to 13 of 1497 rows
And I check table result pagination for PaginationTable page
|noId|first_name|last_name|email|
|1|Abbba|Baaba|big0@data.com|
|2|Left|Right|big1@data.com|
And I close and log out
答案 0 :(得分:2)
我将在下面回答您的问题,但我认为这可能是情景大纲的一种情况,这将允许您以不同的方式重用您的表格。除了单击的元素外,您的方案是相同的。这个尖叫场景大纲。
只要看看你的小黄瓜,感觉就像你有太多的特异性并且正在进行一项脆弱的测试,但你知道你在那里有什么数据以及在测试运行期间如何加载/管理它们。只是想一想。
回答您的问题
Cucumber不直接支持此类功能,但是如果您使用后台步骤进行设置,则可以在那里构建表并重复使用,但只能在同一个功能文件中。它不适用于功能文件。
在给出的背景中,只需将表存储为变量并在步骤中引用该表。
Background:
Given I expect table result pagination to be:
|noId|first_name|last_name|email |
|1 |Abbba |Baaba |big0@data.com|
|2 |Left |Right |big1@data.com|
Scenario: At beginning unable to click on first
When On Sidebar page I click element basic table pagination
And On PaginationTable page I click element first
Then On PaginationTable page label pagination info value is Showing 1 to 13 of 1497 rows
And I check table result pagination for PaginationTable page
And I close and log out
Scenario: At beginning unable to click on left
When On Sidebar page I click element basic table pagination
And On PaginationTable page I click element left
Then On PaginationTable page label pagination info value is Showing 1 to 13 of 1497 rows
And I check table result pagination for PaginationTable page
And I close and log out
使用方案大纲的替代实施
Scenario Outline: At beginning unable to click on element
When On Sidebar page I click element basic table pagination
And On PaginationTable page I click <element>
Then On PaginationTable page label pagination info value is Showing 1 to 13 of 1497 rows
And I check table result pagination for PaginationTable page
|noId|first_name|last_name|email|
|1|Abbba|Baaba|big0@data.com|
|2|Left|Right|big1@data.com|
And I close and log out
Examples:
| element |
| first |
| left |