下面是我的脚本。
def FilePath = testRunner.testCase.getPropertyValue("FOLDER_PATH")
def FileName = testRunner.testCase.getPropertyValue("FILE_NAME")
def file = new File(FilePath+"\\"+FileName)
log.info(file)
def destination = testRunner.testCase.testSuite.project.getPropertyValue("FILE_DEPOSITORY")
log.info(destination)
if(file.exists())
{
file.copyfile(FileName,FilePath,destination)
} else
{
log.info("A file named " + FileName + " does not exisits at the path "+FilePath)
}
我得到了以下异常:groovy.lang.MissingMethodException.No signature of method: java.io.File.copyfile()是适用于参数类型的。没有方法的签名:java.io.File.copyfile()适用于参数类型。(java.lang.String, java.lang.String, java.lang.String)值。[filename, sourepath, destination path] 可能的解决方案:第15行的isFile()错误。
在本地测试,并工作。
def Source = testRunner.testCase.getPropertyValue("FOLDER_PATH")
def FileName = testRunner.testCase.getPropertyValue("FILE_NAME")
def AbsoluteSource = new File(Source + "\\" + FileName)
def Destination = testRunner.testCase.getPropertyValue("DESTINATION")
def AbsoluteDestination = new File(Destination + "\\" + FileName)
if (AbsoluteSource.exists()) {
AbsoluteDestination << AbsoluteSource.bytes
} else {
log.info("A file named " + FileName + " does not exisits at the path " + Source)
}