【问题标题】:Cucumber - How to run a feature file with multiple Scenario in the same template?Cucumber - 如何在同一模板中运行具有多个场景的功能文件?
【发布时间】:2016-04-28 08:09:13
【问题描述】:

我有 1 个这样的功能文件

功能:Swissdec 工资单

Scenario Outline:
Given Payslips based on the swissdec example salary item types (and formulas).

Scenario: SwissdecPaySlips01: the employee is in working age and get correct payslip with AHV_DEDUCTION
Given we use employee with name "Peter Bosshard"
    And Company with name "Muster AG"
    And Monthly salary of CHF 100000.00
    And Salary Item Type is attached: 1000, 5000, 9010, 5010
When the payslip for 04.2016 is requested
Then we get a payslip with the following items
    | 1000 | MONTHLY_SALARY                 | 100000.00 |
    | 5000 | GROSS_SALARY                   | 100000.00 |
    | 9010 | AHV_BASIS                      | 100000.00 |
    | 5010 | AHV_DEDDUCTION                 |  -5125.00 |
    And a period from 2016.04.01 to 2016.04.30  

Scenario: SwissdecPaySlips02: the employee is in working age and get correct payslip with AHV_DEDUCTION
Given we use employee with name "Hoang Nguyen"
    And Company with name "Axon Active"
    And Monthly salary of CHF 100000.00
    And Salary Item Type is attached: 1000, 5000, 9010, 5010
When the payslip for 04.2016 is requested
Then we get a payslip with the following items
    | 1000 | MONTHLY_SALARY                 | 100000.00 |
    | 5000 | GROSS_SALARY                   | 100000.00 |
    | 9010 | AHV_BASIS                      | 100000.00 |
    | 5010 | AHV_DEDDUCTION                 |  -5125.00 |
    And a period from 2016.04.01 to 2016.04.30  

问题是,每次我运行这个黄瓜测试用例。每一步:

@Given("^we use employee with name \"([^\"]*)\"$")
public void we_use_employee_with_name(String employeeName) {
}

将运行 2 次。因为它与2个场景中的2个步骤相匹配

如何按场景和逐步从上到下运行测试场景?

谢谢

【问题讨论】:

    标签: testng cucumber-jvm


    【解决方案1】:

    最佳实践是为场景中的特征使用标签并使用运行器类执行它们,例如:

    @tag1 设想: 步骤

    @tag2 设想: 步骤

    如果你能解释一下这个问题会很好

    【讨论】:

    • 感谢您的反馈,我已经解决了我的问题。 @Ranjith 的
    【解决方案2】:

    这个问题是因为即使我提供了文件系统地址,也没有正确引用功能文件。在将胶水更正为仅功能文件的包名称时,它起作用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-06
      • 2018-08-25
      • 2020-03-11
      • 2016-03-24
      相关资源
      最近更新 更多