Unable to run testrunner.bat via Command Prompt.
Hi,
I'm using SoapUI 5.5.0 OS version and the problem is:
To get a extent report I have created a build file and triggering via cmd, but getting following error Execute failed: java.io.IOException: Cannot run program "testrunner.bat"
Where as if I directly trigger testrunner.bat via cmd it's working
Command line - testrunner.bat -s "xxx" -c"xxx" -r -f "xxx" -t "xxx" "projectPath"
Below is the build.xml script:
<project name="accounts" default="testreport" basedir=".">
<property name="test.suite" value="TestSuite 1"/>
<property name="test.case" value="DataDriven Demo2" />
<property name="soapui.project" value="F:\Profile\SoapProjects\accounts.xml"/>
<property name="soapui.home" value="C:\ProgramFiles\SmartBear\SoapUI-5.5.0" />
<property name="soapui.settings" value="F:\Profile\soapui-settings.xml" />
<property name="results.dir" value="F:\SoapProjects"/>
<property name="reports.dir" value="${results.dir}/Reports"/>
<property name="html.dir" value="${reports.dir}/html"/>
<target name="execute.project">
<exec dir="${soapui.home}\bin" executable="testrunner.bat">
<arg line="-s ${test.suite} -c ${test.case} -r -f ${results.dir} -t ${soapui.settings} ${soapui.project}" />
</exec>
</target>
<target name="testreport" depends="execute.project">
<mkdir dir="${reports.dir}" />
<junitreport todir="${reports.dir}">
<fileset dir="${results.dir}">
<include name="Test-*.xml"/>
</fileset>
<report format="noframes" todir="${html.dir}" />
</junitreport>
</target>
</project>
Below is the response after executing ant command:
BUILD FAILED
F:\Profile\SoapProject\build.xml:11: Execute failed: java.io.IOException: Cannot run program "testrunner.bat" (in directory "C:\ProgramData\ProgramFiles\SmartBear\SoapUI-5.5.0\bin"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:428)
at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:442)
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:629)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:670)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:496)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:853)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:444)
at java.lang.ProcessImpl.start(ProcessImpl.java:140)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 24 more
Kindly help to identify the root cause and solution.
Thanks in advance.
Solution for java.io.IOException: Cannot run program "testrunner.bat" while running build.xml via command prompt.
Small change need to be done in build.xml file, below is the altered script highlighted in red:
<project name="accounts" default="testreport" basedir=".">
<property name="test.suite" value="TestSuite 1"/>
<property name="test.case" value="DataDriven Demo2" />
<property name="soapui.project" value="F:\Profile\SoapProjects\accounts.xml"/>
<property name="soapui.home" value="C:\ProgramFiles\SmartBear\SoapUI-5.5.0\bin" />
<property name="soapui.settings" value="F:\Profile\soapui-settings.xml" />
<property name="results.dir" value="F:\SoapProjects"/>
<property name="reports.dir" value="${results.dir}/Reports"/>
<property name="html.dir" value="${reports.dir}/html"/>
<target name="execute.project">
<exec dir="." executable="${soapui.home}\testrunner.bat">
<arg line="-s ${test.suite} -c ${test.case} -r -f ${results.dir} -t ${soapui.settings} ${soapui.project}" />
</exec>
</target>
<target name="testreport" depends="execute.project">
<mkdir dir="${reports.dir}" />
<junitreport todir="${reports.dir}">
<fileset dir="${results.dir}">
<include name="Test-*.xml"/>
</fileset>
<report format="noframes" todir="${html.dir}" />
</junitreport>
</target>
</project>