如何在空手道特征中循环绕阵列值

发布于 2025-01-31 03:36:35 字数 524 浏览 1 评论 0原文

我正在尝试在空手道功能文件中循环浏览数组值。 在功能1.feature -scenario1中,我在数组中有一些值[“ uuid1”,“ uuid2”,“ uuid3”],我想调用另一个功能文件(feature2.feature)(有代码可以调用delete Endpoint )服务功能

。Feature:

 @ignore

Feature: Delete

  Background:

    * url baseUrl
    * headers {content-type:'application/json'}

  Scenario: Delete Test Assets

    Given headers {uid: '#(UId)', cid:'#(CId)'}
    And path 'type', Type, 'id', AssetId
    When method delete
    Then status 204

我应该用哪种方法来feature1.feature调用feature2.Feature循环中?

I am trying to loop over array values in a karate feature file.
In a Feature1.feature - Scenario1, I have some values in the array ["UUID1","UUID2","UUID3"] and I want to call another feature file (Feature2.feature) (having a code to call a DELETE endpoint) of a service

Feature2.feature:

 @ignore

Feature: Delete

  Background:

    * url baseUrl
    * headers {content-type:'application/json'}

  Scenario: Delete Test Assets

    Given headers {uid: '#(UId)', cid:'#(CId)'}
    And path 'type', Type, 'id', AssetId
    When method delete
    Then status 204

What approach should I use to Feature1.feature to call the Feature2.feature in a loop?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事和酒 2025-02-07 03:36:35

如果您有各种原始图,则需要在执行“循环调用”之前将其转换为JSON对象。请参阅karate.mapwithkey() htttps:// github.com/intuit/karate#json-transforms

这样做:

* def data =  ["UUID1","UUID2","UUID3"]
* def data = karate.mapWithKey(data, 'uid')
* call read('second.feature') data

in second.feature

* headers { uid: '#(uid)' }

当然,请阅读Call> Call> Call的文档,如果需要: https://github.com/intuit/karate#data-data-data-data-data-data-data-data-data-data-data-data-data-data-data-data-data-data-data-data-dr例>

If you have an array of primitives, you need to convert it into an array of JSON objects before doing a "loop call". Refer to the docs for karate.mapWithKey(): https://github.com/intuit/karate#json-transforms

So do this:

* def data =  ["UUID1","UUID2","UUID3"]
* def data = karate.mapWithKey(data, 'uid')
* call read('second.feature') data

And in second.feature:

* headers { uid: '#(uid)' }

Of course, read the docs for call if needed: https://github.com/intuit/karate#data-driven-features

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文