空手道中的一个标题之一编辑(更新,删除)

发布于 2025-01-24 15:30:04 字数 328 浏览 1 评论 0原文

该标头在一个.js文件中,我正在使用

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

问题#1

  • 我有一个标题, 读取此标题使用我的方案数据? 我尝试设置*标头'xyz'='value',但它不编辑它。

问题#2

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

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')

Question #1

  • 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.

Question #2

  • If I want to delete one of the headers, how is it possible?

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

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

发布评论

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

评论(1

≈。彩虹 2025-01-31 15:30:04

因此,90%的方案是“快乐路径”,并且您配置了标题 JS。

现在,您需要一些方案才能拥有更多(或更少的标题)。一个选项是为这些方案进行硬编码标头,请注意,您可以执行*配置标题= null以禁用“自动”标头。然后使用标头(或标题)关键字,然后手动构建标头。

另一个选择是您可以调用标题功能并获取JSON-然后在设置标头手动< / em>之前突变(添加 /删除键)。例如:

# 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

因此,上面的优势是,如果您的标题例程很复杂,则可以重新使用它 - 但仍然具有细粒度的控制。

有关更多想法,请参见: https://stackoverflow.com/a/a/766672675/143475

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

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.

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.

For more ideas, see: https://stackoverflow.com/a/76672675/143475

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