在某些情况下,在后台初始化的路径变量将被重置 [英] path variable initialized in the background gets reset for some scenarios

查看:42
本文介绍了在某些情况下,在后台初始化的路径变量将被重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个主要功能文件,其中包含约80种场景,其中包括测试POST和GET请求,其中一些称为辅助功能文件,它们从不同的REST端点获取数据.在主要功能文件中,我们有背景"部分,在其中设置路径变量.我注意到在某些情况下此路径变量会重置(只是为空).我不确定是什么原因造成的,但是它们的共同之处是它们都是POST请求.为了解决这个问题,我正在这样做:

We have a main feature file with about 80 scenarios mixed of testing POST and GET request, and some of them called auxiliary feature files that get data from different REST endpoints. In the main feature file, we have Background section where we set a path variable. I noticed that this path variable gets reset (just empty) for some scenarios. I'm not sure what causes this, but one common thing they have are that they are all POST requests. To resolve this problem, I'm doing this :

Given path 'part1/version/part2/' + ENCRYPT('123')

即使我在背景部分中有以下一行

even though I have the following line in background section

* path 'part1/version/part2/'

我很好奇是什么导致空手道重置路径变量.

I'm curious what causes karate to reset path variable.

推荐答案

是的,这是设计使然. path始终在HTTP请求后清除.这是为了简化REST-ful URL的处理.实际上,"hello world"示例本身就利用了这一点.

Yes, this is by design. The path is always cleared after an HTTP request. This is to make handling REST-ful URL-s easier. In fact the "hello world" example itself uses this to its advantage.

如果您希望重置URL,请将其包含在url中.

If you want the URL to not reset, include it in the url.

* url myBaseUrl + '/part1/version/part2'

文档中所述: https://github.com/intuit/karate#path

这篇关于在某些情况下,在后台初始化的路径变量将被重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆