如何使用该场景作为其他场景的先决条件

问题描述 投票:1回答:1

第一个功能文件

Feature: CRMSmokeTest
    In order to make sure that CRM Key functionalities working as expected.
Background:     
    Given I have entered the CRM URL

Scenario Outline:Quick Search using AccountID
    Given AccountID is selected in The Quick Search
    When user enter the <AccountID> in search field
    And Click on Quick Search button
    And Close the Alerts
    Then Title of the page contains <AccountID>
    Examples:
    | AccountID |
    | 116999    |

第二特征文件

Feature: CRM Ticket Open, Add and Amend
    In order to verify thay user able to open and amend existing ticket
    Also to verify that user is able to create a new Ticket
Background: 
Given I have entered the CRM URL
And AccountID is selected in The Quick Search
@mytag
Scenario Outline: Add a new Ticket
    When user enter the <AccountID> in search field
    And  Click on Quick Search button
    And  Close the Alerts
    Then Title of the page contains <AccountID>
    When User click on Add New link on Ticket Section
    And Select the <Departmnet> and <SubTeam> from the list
    And Enter the <Subject> of the ticket
    And Select the <Product>
    And Select the <TicketCategory> and <TicketSubCategory>
    And Enter the <Comments> and <PersonSpokeTo>
    And Click on Finish
    Then A new Ticket is created
Examples: 
| AccountID | Department        | SubTeam         | Subject     | Product        | TicketCategory     | TicketSubCategory | Comments      |
| 116999    | Customer Services | ContractEnquiry | Test Ticket | Home Insurance | Account Management | Customer Zone     | Test Comments |

我想将第一个功能文件中的方案用作第二个功能文件中方案的先决条件。

  1. 最佳实践是什么

  2. 另外,当填写大数据表单时,编写方案的最佳方法是什么。我在第二个功能文件中编写方案的方法是唯一的方法,或者我们可以编写这种更好的方法?

selenium cucumber bdd specflow gherkin
1个回答
0
投票

由于满足当前方案的先决条件而调用另一个方案破坏了使每个方案能够独立运行所需的隔离。任何方案都不应依赖任何其他方案。

而不是复制和粘贴第一个方案中的步骤,而是写一个简短的Given步骤,该步骤执行与第一个方案相同的操作。

根据场景标题判断,创建一个类似于以下内容的Given步骤:

Scenario Outline: Add a new Ticket
    # New 'Given' step that basically does the same thing as scenario #1
    Given user performed a quick search for account <AccountID>

    # Now continue on with the rest of the scenario
    When User click on Add New link on Ticket Section
    And Select the <Departmnet> and <SubTeam> from the list
    And Enter the <Subject> of the ticket
    And Select the <Product>
    And Select the <TicketCategory> and <TicketSubCategory>
    And Enter the <Comments> and <PersonSpokeTo>
    And Click on Finish
    Then A new Ticket is created

Examples: 
    | AccountID | Department        | SubTeam         | Subject     | Product        | TicketCategory     | TicketSubCategory | Comments      |
    | 116999    | Customer Services | ContractEnquiry | Test Ticket | Home Insurance | Account Management | Customer Zone     | Test Comments |

此步骤的实现将取决于测试的体系结构,但该步骤应:

  1. 转到CRM URL
  2. 在快速搜索中选择AccountId
  3. 在搜索框中输入给定的帐户ID
  4. 单击快速搜索按钮
  5. 显示时关闭警报

[如果发现自己编写的代码似乎在其他步骤中存在,请考虑将代码重构为Page Models,然后初始化这些页面模型并从您的步骤定义中调用方法。测试的基本控制流程将进行:

Feature file --> Step definition --> Page model --> Selenium --> Web browser
© www.soinside.com 2019 - 2024. All rights reserved.