Showing results for 
Search instead for 
Did you mean: 

SOAPUI Groovy to run .exe files

New Contributor

SOAPUI Groovy to run .exe files

Hi Team,

I wanted to run exe file as part of my SOAPUI test case execution. And i'm trying to figure out a way to run exe file and capture response in the groovy script from SOAPUI.
Can someone provide a lead to do this? 

Regular Contributor

Re: SOAPUI Groovy to run .exe files


I did something like this through the use of batch files (as they are launched on a remote simulator PC), though I did not launched the .exe directly.

I describe it below, hoping it can help :


For instance, I have a .bat file that launches simulator exe as follows:


start %2\\WaterMeter -KNXAddressIndex 2/0/22 -KNXAddressFlow 2/0/23 -IPserver %1 -DeviceName \"Water1\" -RefresRate 10 -PulseMode 4
ping -n 1 -w 10 > nul


in that line the exe name is WaterMeter.exe, the rest concerns launching parameters. the %1 and %2 data are batch parameters that are set in the command line launched in the groovy step.

The groovy step is the following (the interesting part is at the end) :


// launch the required simulators for non reg execution 

// use domo-simu server
def simulator_ip = context.expand( '${#Project#DOMO-SIMU_address}' )
def simulator_path = context.expand( '${#Project#simu_tools_path}' )
def simulator_name = context.expand( '${#TestCase#simulator_name}' )

    case "generic":
        file = "launch_generic_simu.bat"
    case "hot_water":
        file = "launch_hot_water_simu.bat"
    case "electricity":
        file = "launch_electric_meters_simu.bat"
    case "gas":
        file = "launch_gas_meters_simu.bat"
    case "water":
        file = "launch_water_meters_simu.bat"
    case "ventilation":
        file = "launch_ventilation_simu.bat"
    case "close":
    		file = "closeAll.bat"
    case "All" :
    default :
        file = "launch_simulators.bat" // launch all available simulators

cmd = simulator_path + "\\$file " + simulator_ip + " " + simulator_path "cmd = $cmd"
process = Runtime.runtime.exec(cmd)




This process allows me to send my simulator interfaces.

command parameters :

- Simulator_path+file is the path where the batch file is.

- simulator_ip is specific to my case as the server that pilots the simulator interface is on a remote PC

- the last simulator_path data is, if I remember well, the location from where you launch the .exe


You will probably not need to proceed this way. Setting your paht/appli.exe in cmd then launch the process will be sufficient.

I don't deal with return data, though the 'process' variable should help you to get some information.

New Contributor

Re: SOAPUI Groovy to run .exe files

Thanks @krogold for your response. For now I'm using below to run the .exe with the help of .bat file. It is successfully launching the .exe file. But, the issue here is I'm not getting complete response in the groovy. receiving only a part of response (even after changing no.of characters in the char buffer) .
Is it possible to get complete response? (I'm not sure it is possible or not but, I'm looking response something like which we get in any of the IDE)


ProcessBuilder pb = new ProcessBuilder("cmd","/c","C:\\dummy.bat")
Process p = pb.start()
InputStreamReader isr = new InputStreamReader(p.inputStream)
char[] cbuf = new char[1024]; //read 1024 characters, increse to higher amount if necessary; String(cbuf))


Community Hero

Re: SOAPUI Groovy to run .exe files

Have you tried the name of exe file in place of 3rd argument? If not try it out.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors