0

Code:

val someVariableIWantToSave    //I do not know what to do here

When("""^this request is sent to the XYZ service:$"""){ (requestData:DataTable) =>
 //// we might want to do somethign else with Datatable in the mapping of the       feature, nothing yet
var someVariableIWantToSave = requestData.asMaps()

}

I mean the asMaps method returns a List[Map[String,String]] type and I want to save it to the someVariableIWantToSave val so I can use it in other steps, but I am not sure what to initialize it to and how to map it properly without a lot of code noise.

4

2 回答 2

0

这是我的解决方案。因为这只是使用 var 的测试代码在这里是可以的。我在测试中将它设置为全局,然后其他步骤可以使用它...

var request: java.util.List[java.util.Map[String, String]] = _

When("""^this request is sent to the blah service:$"""){ (requestData:DataTable) =>
request = requestData.asMaps() 
} 

`

于 2012-11-10T00:33:47.150 回答
0

您不能“将某些内容保存到 a val”,因为vals 无法更改。由于您只是在此步骤中而不是在其他步骤中获取请求数据,因此您应该只有

When("""^this request is sent to the XYZ service:$"""){ (requestData:DataTable) =>
  val someVariableIWantToSave = requestData.asMaps()
  // do something with someVariableIWantToSave
}
于 2012-11-09T05:22:34.873 回答