我必须在spock表中存储多个数据。当需要时我必须通过参数值传递数据,根据它应该在spock表中搜索,选择相应的数据。请查看代码并进行更正。 实施我的项目对我非常有帮助。
def passW = "Publisher"
def "getPassword" (passW) {
expect:
if (secureKeyword == passW ) {
println "Result is " + encryptPass
}
where:
secureKeyword || encryptPass
"Author" || "aW50ZWxAMTIzNCE="
"Publisher" || "tsdwerDhV76wYCf="
}
结果应为:tsdwerDhV76wYCf =
答案 0 :(得分:0)
您可以将模块数据存储在静态(或@Shared)集合中,并在findAll闭包的where部分中过滤测试输入。
def static moduleCredentials = ["Author":"aW50ZWxAMTIzNCE=",
"Publisher":"tsdwerDhV76wYCf="]
@Unroll
def "Module #module.key login credentials test"(){
def moduleName = module.key
def modulePass = module.value
println(moduleName+":"+modulePass)
expect:
assert modulePass
where:
module << moduleCredentials.findAll {it.key=="Author"}.entrySet()
}