为什么以下测试未通过?对于复制的工作原理,我一定缺少一些基本知识。它似乎是对json对象的引用,而不是副本。
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"
答案 0 :(得分:2)
始终解开call
的结果。原因是特定的JSON对象是“特殊”(Java映射),它不遵循copy
的规则-因为您可以引用其他Java对象。这样就可以了:
@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"