如何复制调用结果

how to make a copy of the result of a call

为什么下面的测试没有通过?我一定遗漏了一些关于复制工作原理的基本知识。它似乎引用了 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"

总是解包 call 的结果。原因是特定的 JSON 对象是 "special"(一个 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"