访问可重用功能调用的 responseBytes

Access responseBytes of a reusable feature call

我想访问可重用功能的 responseBytes 并将其与本地文件进行比较。 在这个例子中我有两个特征文件。文件 general.feature 应该调用 loadPicture.feature 并访问其 responseBytes。 我的想法是我可以执行以下操作:

general.feature:

* def pictureCall = call read('loadPicture.feature')
Then match pictureCall.responseBytes == read('file.jpeg')

但是,此操作失败并显示消息:

path: $.responseBytes, actual: null, expected: java.io.FileInputStream@353f377a, reason: actual json-path does not exist

然而,在可重复使用的功能中,我可以毫无问题地执行以下操作

loadPicture.feature:

Then match responseBytes == read('file.jpeg') 

即使我将 responseBytes 存储在变量中的可重用功能中,它也无法按预期工作:

loadPicture.feature:

* def pictureBytes = responseBytes
general.feature:

* def pictureCall = call read('loadPicture.feature')
Then match pictureCall.pictureBytes == read('file.jpeg')

唯一有效的是以下内容:

loadPicture.feature:

* bytes pictureBytes = responseBytes
general.feature:

* def pictureCall = call read('loadPicture.feature')
And bytes image = read('file.jpeg')
Then match image == pictureCall.pictureBytes

这里让我感到困惑的是以下再次不起作用:

loadPicture.feature:

* bytes pictureBytes = responseBytes
general.feature:

* def pictureCall = call read('loadPicture.feature')
Then match pictureCall.pictureBytes == read('file.jpeg')

这有解释吗?跟变量的类型有关系吗?

是的,responseBytes 很特殊,在内部我们不会将其作为优化传递。正如您想象的那样,这会很快使内存膨胀。

欢迎您贡献代码以改进此功能或更新文档。