| Cogitek RIATest 3 Documentation | Copyright © Cogitek Inc. |
To run tests from a command line you need to use the command line option /b. When RIATest is invoked with this parameter it works in 'batch' mode. In batch mode no GUI is opened, RIATest is only capable of running tests. To specify the project to run you need to use option /p. You will also need to tell RIATest to run the project using option /r. So the minimum command line to run a project in batch mode is the following:
riatest.exe /b /r /p c:\mypojectdir\myproject.rtp
It will execute and return exit code 0 on success or other exit codes on failure. You can also use the environment variable RIATEST3:
"%RIATEST3%\riatest.exe" /b /r /p c:\mypojectdir\myproject.rtp
The RIATEST3 variable points to the installation directory not to riatest.exe. This is done on purpose so that you can also refer to other files such as "%RIATEST3%\agent\RIATestAgent3.swc" in the build tool.
To run RIATest in batch mode on the Mac OS X use the following command:
"/Applications/RIATest 3/RIATest.app/Contents/MacOS/RIATest" -b -r -p Components.rtp
You can also add RIATest to the PATH to make the command line shorter. Add the following to your .bash_profile file in your home directory:
export PATH=$PATH:/Applications/RIATest 3/RIATest.app/Contents/MacOS/
You can now use a shorter command to execute RIATest:
RIATest -b -r -p Components.rtp
You can use Ant's built-in exec task to call RIATest from your ant projects. For example:
<target name="test" description="test the project">
<property environment="env"/>
<exec dir="." executable="${env.RIATEST3}\riatest.exe" failonerror="true">
<arg line="/b /r /p Components.rtp"/>
</exec>
</target>
If the failonerror attribute is set to true, the entire Ant build will fail if RIATest test fails (riatest.exe returns non-zero value).
Normally the batch mode will run the entire project specified by option /p. However sometimes you may want to run only a few scripts or groups from the project. This can be specified in two ways: by supplying scripts to execute on a command line (option /rs) or by supplying a file that will list the scripts to run (option /rf).
Important: options /rs and /rf are effective only when used in combination with option /b.
Option /rs allows you to specify individual scripts or groups to run. The /rs option should have a list of scripts/group to enable (using + sign) or disable (using - sign) from running. The separator symbol for the list is a semicolon.
For example we have two groups: GroupA and GroupB, GroupA contains scripts Script1.rts and Script2.rts and GroupB contains Script3.rts and otherdir/Script4.rts. Note that Script4.rts is located in otherdir sub-directory.
To run only Script3.rts use command line /rs -//GroupA;-//GroupB;+//GroupB//Script3.rts or simply /rs -//;+//GroupB//Script3.rts
To run Script1.rts from GroupA and Script3.rts from GroupB use command line /rs -//;+//GroupA//Script1.rts;+//GroupB//Script3.rts
To run only Script4.rts use command line /rs -//;+//GroupB//otherdir/Script3.rts
Note the use of single slash to separate script file's directory and file name.
The rules for /rs option specifier are:
The /rf option allows you to list the scripts to run in an external file. The external file must be in INI format. RIATest will read section [ProjectView/DisabledScripts] and will NOT run scripts found in this section. The format of the file is the same as the .rtw file generated by RIATest IDE so you can run RIATest, open your project, enabled/disable scripts/group the way you want, exit RIATest and the .rtw file will contain [ProjectView/DisabledScripts] that you can copy to your own file and pass it using /rf option.
When running in batch mode RIATest can output the results of the test execution to plain text (option /o) or XML files (option /ox). If you want the results to be in HTML format you need to use the separate rtxml2html converter utility. First, tell RIATest to run the tests and output results to XML file:
riatest.exe /b /r /p c:/myproj.rtp /ox results.xml
Once the tests are finished use rtxml2html to convert the results to an HTML file:
rtxml2html /i results.xml /o results.html
If you need to pass data to your scripts when running the scripts from the command line you need to use option /d and the script function getProjectGlobal().
From the command line pass data this way:
riatest.exe /b /r /p c:/myproj.rtp /d "name1=val1;name2=val2"
Note that multiple values are supported and should be delimited by a semicolon.
In your scripts read the values are passed from the command line in this way:
var val = getProjectGlobal("name1");
| /b | Batch mode, no GUI. Useful for running from command line, from batch files and from build tools. Usually combined with /r and /p to run a project. |
| /e number | Maximum error limit for scripts execution, 0 - no error limit. If specified number of errors is encountered the execution is aborted. |
| /l launch-action | Set launch action. Either one of predefined actions: default,ie,firefox or a command line to execute (e.g. "cmd.exe /c") |
| /o output-file-name | Write output messages to specified file. Only has effect if combined with /b parameter. |
| /ox output-file-name | Write output messages in XML format to specified file. Only has effect if combined with /b parameter. |
| /p path-to-project-file | Open the specified project in IDE or run it if combined with /r |
| /r | Run the project specified by parameter /p |
| /t seconds | Maximum execution time in seconds. If execution takes longer than specified seconds it is aborted. |
| /d "name1=val1;name2=val2;..." | Predefine project global variables (access from script using getProjectGlobal() function). |
| /rf filename | Read section "[ProjectView/DisabledScripts]" from filename and do not run scripts found in this section. Format of the file is the same as .rtw file generated by RIATest IDE. |
| /rs +script1;-group1//script2;+group2 | Enable or disable certain scripts and/or groups for execution. Use + to enable, - to enable followed by script or group name. Use double quote character for script/group names that contain spaces, e.g.: /rs "-//Group 1;+//Group 1//Group 11;-Group 1//Group 11//Group11Script2.rts" |
When executed in batch mode riatest.exe returns the following exit codes:
| 0 | Success. Also returned when no errors are encountered during execution of tests |
| 1 | Nothing to do. Happens if you use /b without /r |
| 2 | Invalid command line parameters |
| 3 | Invalid output file specified (or cannot open specified file) |
| 4 | Cannot open specified project file |
| 5 | Errors encountered during execution of scripts |
| 6 | Timed out waiting for agent connection |
| 7 | Agent unexpectedly disconnected |
| 8 | Aborted due to execution time limit violation |
| 9 | Aborted due to error count limit violation |
| 10 | Invalid license (or cannot acquire license) |
| >=127 | Internal errors |