本文介绍了如何复制通话结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么以下测试未通过?我一定缺少一些有关复制工作原理的基本知识.它似乎是对json对象的引用,而不是副本.
Why does the following test not pass? I must be missing something fundamental about how copy works. It seems to have a reference to the json object and not a copy.
Feature: testing
@one
Scenario: one
* def root = { name: 'inner' }
Scenario: two
* def a = call read('testing.feature@one')
* copy b = a
* set b.root.name = "copy"
* match b.root.name == "copy"
* match a.root.name == "called"
推荐答案
始终解开call
的结果.原因是特定的JSON对象是特殊的"(Java映射),它不遵循copy
的规则-因为您可以引用其他Java对象.这样就可以了:
Always un-wrap the results of call
. The reason is that particular JSON object is "special" (a Java map) which does not follow the rules of copy
- because you can have references to other Java objects. So this will work:
@one
Scenario: one
* def root = { name: 'inner' }
Scenario: two
* def temp = call read('dev.feature@one')
* def a = temp.root
* copy b = a
* set b.name = "copy"
* match b.name == "copy"
* match a.name == "inner"
这篇关于如何复制通话结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!