Controlling FTPTestStep from groovy
Hello there
I am currently stuck trying to transfer files with the FTP-Step provided in SoapUI Pro. The files are generated before sending, and there may be a large amount of files to send.
The amount of files to send are determined after generation, I currently use a loop to iterate through all the files and add their information to the FTP-Step and then run it. Basically boiled down it's the following code:
new File(path).listFiles().each{ ftpStep.setLocalPath(it.getPath()) ftpStep.setFileName(it.getName()) ftpStep.run(testRunner, context) }
Sadly the transfer seems to fail every time, providing the following error:
Unable to upload the file: null
Looks to me like the testRunner gets confused and is unable to apply the filePath properly. testRunner and context are passed down from the invoked variables.
If I execute the FTP-Step without any modifications afterwards, it sends the previously configured file to the server without problems, so I can only assume that something with the run() function is not working properly.
I would appreciate any sort of help or workaround - but just confirming my problem would be sufficient for me to create a bug ticket
Thanks to the support for solving the problem:
The ftpStep requires two additional method calls to properly transmit files, using the provided example in the OP the correct way to use the run method would be as follows:
new File(path).listFiles().each{ ftpStep.setLocalPath(it.getPath()) ftpStep.setFileName(it.getName()) ftpStep.prepare(testRunner, context) ftpStep.run(testRunner, context) ftpStep.finish(testRunner, context) }