1

在以下功能文件中,我的要求是doc_id每三个字段放置一个。为了澄清,我想检查ProductNamemanufacturerName并且RevisionDate对于每个doc_id. 我想出了以下方法,但我认为这绝对不是首选方法。谁能给我一个更好的方法。

Background:
    Given I am in landigpage page after login

Scenario Outline: valid
    When I enter "<doc_id>"
    And I click the search go button
    Then I should get in vault search page
    And Search result of "<field>" should match with database

Examples:
    | doc_id | field            |
    | 15     | ProductName      |
    | 15     | ManufacturerName |
    | 15     | RevisionDate     |

Examples:
    | doc_id | field            |
    | 16     | ProductName      |
    | 16     | ManufacturerName |
    | 16     | RevisionDate     | 
4

3 回答 3

1

嗨,我猜你们正在混淆数据表和场景大纲。上面的解决方案是:

Background:
Given I am in landingpage page after login

Scenario Outline: valid
When I enter "<doc_id>"
And I select to navigate to search page 
Then Search result of field should match with database
| ProductName      |
| ManufacturerName |
| RevisionDate     |

Examples:
  | doc_id |
  | 15     |
  | 16     |

该表可以轻松转换为您可以在步骤中使用的列表或地图。

于 2016-02-03T09:46:23.413 回答
1

您可以使用单个示例表:

Background:
    Given I am in landigpage page after login

Scenario Outline: valid
    When I enter "<doc_id>"
    And I click the search go button
    Then I should get in vault search page
    And Search result of "<field>" should match with database

Examples:
    | doc_id | field            |
    | 15     | ProductName      |
    | 15     | ManufacturerName |
    | 15     | RevisionDate     |
    | 16     | ProductName      |
    | 16     | ManufacturerName |
    | 16     | RevisionDate     | 

我看不到任何其他方式可以按照您需要的方式传递参数。这就是我不喜欢黄瓜的地方。它不是那么灵活。

于 2015-07-28T20:05:19.047 回答
1
Bacckground:
  Given I am in landigpage page after login

Scenario Outline: valid
  When I enter "<doc_id>"
  And I click the search go button
  Then I should get in vault search page
  And the search results should match the database
Examples:
  | doc_id |
  | 15     |
  | 16     |

并使这项工作:

When /^I enter "<\w+>"$/ do | doc_id |
  @doc_id = doc_id
  ...
end

Then "the search results should match the database" do
  db_results = db.find(@doc_id)  # or something similar
  ... # compare db_results to actual results
end

这仍然有点糟糕,因为您的 Gherkin 中有 doc_id,您依赖于预填充的数据库并且您有一个场景大纲;但是,嘿,让我们把它留给其他问题吧:)

于 2015-08-01T13:01:21.183 回答