繁体   English   中英

如何在场景大纲示例(空手道框架)中赋值?

[英]How to put a value in Scenario Outline Examples (karate framework)?

在我的功能中,我有:

* def loc = responseHeaders['location'][10]
* def id = loc.substring(loc.lastIndexOf('/') + 1)

我想在场景大纲示例中使用 id :

Scenario Outline: fkdfslqknfd
    Given url 'foo.com'
    And path <bar>
    When method get
    ......    
        Examples:
          |bar |
          |(id)|
          |"id"|
          |'id'|
          |id  |> The last example is ok.

但是,我没有收到'foo.com/13' (假设 id 是 13),而是收到了'foo.com/id' 我试过#,但它不起作用。 我怎样才能替换这个ID? 我需要测试这个字符串格式的 id。 谢谢

至少在 JSON 参数中,它对我有用

 Examples:
| request_body |
| {username: '#(email)', password: '#(password)'} |

这是 Cucumber 的一个已知限制,即Examples不能是动态的。 请参阅文档的最后一段: https : //github.com/intuit/karate#the-karate-way

如果你真的想用不同的值遍历一个特性,再次参考上面的文档,如果你环顾四周,有很多例子。 看看所有以call-开头的 - 这里: https : //github.com/intuit/karate/tree/master/karate-demo

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM