This isn't a complete walkthrough. This assumes knowledge of Ant, Java, and RFT.
Getting RFT to run under Ant.
For this example, I'm using Ant, as that's what I used. To get your RFT scripts running under the command line, you'll first need to copy all the 3rd party libraries and any proxy classes your RFT scripts relies on to "C:\ProgramData\IBM\RFT\customization". This is the classpath that "rational_ft.jar" uses to reference any 3rd party libraries.<property name="ibm.rational.customizations" value=" C:\ProgramData\IBM\RFT\customization " />The next step is to build your RFT script. For building your RFT script, you'll have to use IBM's rational_ft.jar, to compile your test. Here we are using the Java tag to call the rational_ft with the '-compile' parameter. The '-project' parameter specifies where your source is located (your project), the "-datastore" specifies where you want to compile your tests to.
<target name="deploy_libs">
<copy todir="${ ibm.rational.customizations }">
<fileset dir="${basedir}/libs" />
</copy>
</target>
<target name="deploy_proxy">
<copy file="${basedir}/proxies/myproxylibrary.dll" todir="${ibm.rational.plugins.dir}" overwrite="true" />
<copy file="${basedir}/proxies/myproxylibrary.rftcust" todir="${ibm.rational.plugins.dir}" overwrite="true" />
</target>
<target name="compile">Next step is creating a target to run your test. Here you'll be using the -playback parameter instead and the -datastore parameter becomes an equivalent of a classpath, it let's the rational_ft class know where to look for your test. Here the rational_ft will work like a JVM that's interpreting the test code your compiled earlier. You can specify additional command line arguments such as turning off interactive mode, showing the log viewer, and other RFT run time options. (See http://publib.boulder.ibm.com/infocenter/rfthelp/v7r0m0/index.jsp?topic=/com.ibm.rational.test.ft.doc/topics/RobotJCommandLine.html for other command line options).
<java jvm="${rft.jvm.path}/bin/java.exe" classpath="${path.to.rational_ft.jar}" classname="com.rational.test.ft.rational_ft">
<arg line='-project ${basedir} />
<arg line='-datastore "${basedir}"' />
<arg line='-compile "testfolder.YourTestScript"' />
</java>
</target>
<target name="runtest">
<java jvm="${rft.jvm.path}/bin/java.exe"
classpath="${path.to.rational_ft.jar}" classname="com.rational.test.ft.rational_ft">
<arg line='-datastore "${basedir}"' />
<arg line='-rt.bring_up_logviewer "false"' />
<arg line='-rt.interactive "false"' />
<arg line='-playback "testfolder.YourTestScript"' /> </java>
</target>
Now you have an Ant build file with these targets, you should be able to compile and run your test from the command line.
The final step is making sure your clean up your processes, in case RFT goes haywire and doesn't halt. This can cause future tests to fail as your have a running RFT process that's deadlocked. The following is for Windows, but it's a basic query to get the process ID of a Java process that uses the rational_ft.jar file as the argument. This will retreive the process ID that RFT is using, and will allow you to kill it in the event your test happens to be deadlocked.
<target name="kill_rft">
<!-- Get the PID of RFT so we can kill it -->
<echo>process where "Description like '%java%rational_ft%'" get CommandLine,ProcessId</echo>
<exec executable="wmic" resultproperty="App.state" outputproperty="output">
<arg line="process where "Description like '%java%'" get CommandLine,ProcessId" />
</exec>
<propertyregex property="rft.pid" input="${output}" regexp=".*java.*rational_ft.*\s+(\d+)" casesensitive="false" select="\1" />
<echo message="Killing RFT's PID is: ${rft.pid}" />
<exec executable="cmd">
<arg line='/C taskkill /PID ${rft.pid} /f /t' />
</exec>
</target>
I hope this helps. Good luck with your automation.
1 comment:
i was trying to use Kill RFT ,
but i am gettin error like below
kill_rft:
[echo] process where "Description like '%java%rational_ft%'" get CommandLine,ProcessId
BUILD FAILED
C:\ant\bin\Test10.xml:38: Problem: failed to create task or type propertyregex
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.
Post a Comment