黄瓜 - 如何在同一模板中运行具有多个方案的要素文件?

时间:2016-04-28 08:09:14

标签: testng cucumber-jvm

我有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个步骤匹配

我如何按场景和逐步向下运行测试场景?

由于

2 个答案:

答案 0 :(得分:2)

最佳做法是在功能中使用标签,并使用运行程序类执行它们,例如:

@ TAG1 场景: 步骤

@ TAG2 场景: 步骤

如果你可以解释更多关于发行的信息,那么

答案 1 :(得分:0)

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

相关问题