代码:
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()
}
我的意思是asMaps方法返回一个List [Map [String,String]]类型,我想将它保存到someVariableIWantToSave val,所以我可以在其他步骤中使用它,但我不知道将它初始化为和如何在没有大量代码噪声的情况下正确映射它。
答案 0 :(得分:0)
您无法“将某些内容保存到val
”,因为val
无法更改。由于您只是在此步骤中获取请求数据而在其他步骤中没有,因此您应该只有
When("""^this request is sent to the XYZ service:$"""){ (requestData:DataTable) =>
val someVariableIWantToSave = requestData.asMaps()
// do something with someVariableIWantToSave
}
答案 1 :(得分:0)
var request: java.util.List[java.util.Map[String, String]] = _
When("""^this request is sent to the blah service:$"""){ (requestData:DataTable) =>
request = requestData.asMaps()
}
`