Reputation: 427
I managed to execute a bat file via Groovy
in SoapUI
with Runtime.runtime.exec("cmd /c C:\temp\test.bat")
But I would like to have the bat file in a folder called scripts where my soapui-project file is.
Example:
Soapui-project file.xml
-- Scripts
--- test.bat
Runtime.runtime.exec("cmd /c Scripts/test.bat")
doesn't work. I really need help here.
Upvotes: 0
Views: 1667
Reputation: 21379
In a team, we share the project artifacts with different members and each may use different directory to copy them. So, in such situations absolute path in groovy scripts, like you mentioned, may not work if the directory gets changes.
To hand this, prefix of the path should be variable. And the rest of the path can fixed as the whole artifacts are still unchanged.
To handle that, use below which makes use of project directory as root and it gets that dynamically.
import com.eviware.soapui.support.GroovyUtils
def path = new GroovyUtils(context).projectPath
log.info "Project directory : ${path}"
Runtime.runtime.exec("cmd /c ${path}/Scripts/test.bat")
Upvotes: 1