user3624378
user3624378

Reputation: 427

SoapUI and absolute path

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

Answers (1)

Rao
Rao

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

Related Questions