我是groovy和SOAP UI的新手.我正在使用一个groovy脚本来驱动我对SOAP UI的测试.
我想编写一个脚本来读取人员ID文件,删除第一个文件,设置属性,将文件写回来,而不是我刚读过的文件.
这是我的第一次切入:
List pids = new ArrayList()
new File("c:/dev/pids.csv").eachLine { line -> pids.add(line) }
String pid = pids.get(0);
testRunner.testCase.setPropertyValue( "personId", pid )
pids.remove(0)
new File("c:/dev/pids.csv").withWriter { out ->
pids.each() { aPid ->
out.writeLine(aPid)
}
}
Run Code Online (Sandbox Code Playgroud)
输出显示在SOAP UI上,文件不会被触及.我迷路了.
ArrayList pids = null
PrintWriter writer = null
File f = new File("c:/temp/pids.txt")
if (f.length() > 0){
pids = new ArrayList()
f.eachLine { line -> pids.add(line) }
println("Item to be removed: " + pids.get(0))
//testRunner.testCase.setPropertyValue( "personId", pid )
pids.remove(0)
println pids
writer = new PrintWriter(f)
pids.each { id -> writer.println(id) }
writer.close()
}
else{
println "File is empty!"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
36012 次 |
| 最近记录: |