【问题标题】:Is there any way to run perticular scenario in karate more than one time if specific condition met true?如果满足特定条件,有没有办法在空手道中多次运行特定场景?
【发布时间】:2020-03-04 07:41:51
【问题描述】:

我想多次运行我的特定场景或功能文件。

假设如果用户输入 5,那么我希望我的网址被点击 5 次。

空手道可以吗?任何帮助将不胜感激

【问题讨论】:

    标签: bdd karate


    【解决方案1】:

    是的,请阅读文档:https://github.com/intuit/karate#loops

    但也请参见下面使用dynamic scenario outlines 的示例:

    Background:
    * def fun = function(i){ return { name: 'User ' + (i + 1) } }
    * def data = karate.repeat(5, fun)
    
    Scenario Outline:
    * url 'http://httpbin.org/anything'
    * request __row
    * method post
    
    Examples:
    | data |
    

    所以运行它,看看它是如何工作的,并研究它是如何工作的。

    请注意,data driven features 是一种替代方法,您可以在其中 call 循环中的第二个功能文件。因此,例如在使用karate.repeat() 5 次(如上述Background)之后,您使用data 作为第二个功能文件的参数,该文件会点击您的网址。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-30
      • 2018-06-29
      • 2011-05-12
      • 2022-01-13
      • 1970-01-01
      • 2021-07-26
      • 2014-12-02
      相关资源
      最近更新 更多