本文介绍了在空手道中编辑(更新,删除)标题之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.js文件中有此标头,并且正在使用

I have this header which is in a .js file and I am reading this header using

* configure headers = read('classpath:services/Headers/distheader.js')

问题#1

  • 如何在运行时使用脚本数据编辑此文件中的头之一?我尝试设置* header 'xyz' = 'value',但是它没有对其进行编辑.
  • How can I edit one of the headers in this file at run-time using my scenario data?I tried setting * header 'xyz' = 'value' but it doesn't edit it.

问题2

  • 如果要删除其中一个标题,怎么可能?

推荐答案

因此,您90%的方案都是幸福之路",并且您已配置了headers JS.

So 90% of your scenarios are "happy path", and you have a headers JS configured.

现在,您需要一些方案来具有更多(或更少的标题).一种选择是对这些方案的标头进行硬编码,请注意,您可以执行* configure headers = null来禁用自动"标头.然后使用header(或headers)关键字并手动构建标题.

Now you need some scenarios to have more (or less headers). One option is to hard-code the headers for those scenarios, note that you can do * configure headers = null to disable the "auto" headers. Then use the header (or headers) keyword and build headers manually.

另一种选择是,您可以调用headers函数并获取JSON-然后先进行突变(添加/删除键),然后再手动设置.例如:

Another option is that you can invoke the headers function and get a JSON - and then mutate (add / remove keys) before setting headers manually. For example:

# you can disable headers if needed
* configure headers = null

# headers.feature is: function(){ return { a: 1, b: 2 } }
* def fun = read('headers.feature')
* def temp = fun()
* remove temp.a
* set temp.c = 3

Given url 'https://httpbin.org'
And path 'anything'
And headers temp
When method get
Then status 200

所以上面的优点是万一您的标头例程很复杂,您可以重复使用它-但仍具有细粒度的控制.

So the advantage above is in case your headers routine is complex, you can re-use it - but still have fine-grained control.

这篇关于在空手道中编辑(更新,删除)标题之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 18:21