1 回答

TA貢獻1848條經驗 獲得超6個贊
找到了一種方法來做到這一點。
public class CustomKeywords {
@Keyword
def runBatch(String path) {
def cmd = "cmd /c \"java -jar \"" + path + "\"\"";
runCmd(cmd)
}
def runCmd(String cmd) {
KeywordUtil.logInfo("cmd: ${cmd}")
def proc = cmd.execute();
def outputStream = new StringBuffer();
def errStream = new StringBuffer()
proc.waitForProcessOutput(outputStream, errStream);
println(outputStream.toString());
println(errStream.toString())
if(proc.exitValue() != 0){
KeywordUtil.markFailed("Out:" + outputStream.toString() + ", Err: " + errStream.toString())
}
}
}
添加回答
舉報