【问题标题】:how to run all feature files multiple times with different values for one of the parameter如何使用参数之一的不同值多次运行所有功能文件
【发布时间】:2020-03-22 07:58:36
【问题描述】:

到目前为止,我们有一个configuration.properties,我们在其中为所有必需的参数设置了值,但我需要遍历其中一个参数的多个值(可能以逗号分隔)并为每个参数运行所有功能文件。

【问题讨论】:

    标签: java selenium cucumber


    【解决方案1】:

    我认为 cucumber 中没有将多个参数仅发送到其中一个参数的功能。但我们能做的是在场景大纲中,

    1. 我们可以发送参数逗号分隔
    2. 数组的参数。
    3. 为该数组多次运行这些步骤

    功能文件

    Scenario Outline : Create User
     Given I enter names as <names>
     And I enter class as <class>
     When I click Save
     Then the success message is displayed
    
         Examples:
         |names      |class|
         |Ann,Malissa|5G   |
    

    步骤定义文件

    @Given("I enter names as (.*)")  
    public void GivenIenterName(String names){
            String[] nameList = names.split("\\,");
             for(String x : nameList){
                  /*block of code 
                  to execute*/
             }
            }
    

    【讨论】:

    • 谢谢,会试试的。这仅适用于一个步骤...我仍在寻找在不同步骤和场景中使用它的机会。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-29
    • 2022-01-01
    • 2017-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多