The first step to automating a load test, is creating the actual test. For details on doing so, please see the Getting Started and Working with LoadUI sections of this web site.
Once the test has been created and saved, the next step is to successfully run it using the command line. To do so, open a command prompt and navigate to the LoadUI installation directory. It should contain the loadUI-cmd.bat (loadUI-cmd.sh for *nix, loadUI-cmd.command for mac) executable.
1. Running from the Command Line
To invoke the command line runner with your project, use the -p flag to specify the location of your saved project file. This will load and start your saved project. If it has any limits set, then the test should stop once one of these limits is reached. If not, it will continue to run until manually stopped. In either case, the test execution can be stopped by pressing CTRL + C. For example:
loadui-cmd.bat -p c:\Documents\my-loadui-project.xml
This starts the project itself. If we have any VU Scenarios inside that should be run, then they must either be linked to the Project execution, or started by a scheduler.
1.1. Specifying Limits and Scenarios
Instead of starting the project, we may with to target a specific Scenario in the project for execution. If so, this can be achieved by using the -t flag. We can also customize the limits for the test directly from the command line, using the -L flag. For example:
loadui-cmd.bat -p c:\Documents\my-loadui-project.xml -t MyScenario -L 3600:0:0
The above command would again run the same project as before, but instead of starting the project execution, it would start running the Scenario named MyScenario. It would also run the test for one hour (3600 seconds).
1.2. Specifying Agents
VU Scenarios generally run in a distributed mode, on remote LoadUI Agents. Which Agents to use and which one does what is specified in the project, but this can also be specified using the command line. The -l flag tells LoadUI to run in local mode, where all Scenarios are run only by the local machine. Instead of running locally, we can use the -a flag to specify Agents to run on. The following example shows how to run the previous Scenario on two Agents specified by IP address:
loadui-cmd.bat -p c:\Documents\my-loadui-project.xml -t MyTScenario -a 10.0.0.5 10.0.0.6
1.3. Creating Reports
Finally lets add the creation of reports to our execution; use the -r parameter to specify where to create your report and the -F parameter to specify the desired format (see the Reference for supported formats). For example
loadui-cmd.bat -p c:\Documents\my-loadui-project.xml -r c:\dev\reports -F PDF
will run our project and generate the summary in both PDF and XML format (the XML version is always created).
1.4. Parameterizing tests
You might want to run the same test multiple times, but change a few parameters for each run. This can be done by passing command line options to LoadUI. As an example, let's have a look at how we could run the same LoadUI project multiple times with different endpoints/URL's.
Now you can start LoadUI with a custom endpoint specified from a Bat-script, Maven, Hudson or whatever, like this:
call loadUI-cmd.bat "-DmyCustomEndpoint=http://myWebSite.com" -p my-loadui-project.xml
call loadUI-cmd.bat "-DmyCustomEndpoint=http://myWebSite.com/admin.php" -p my-loadui-project.xml
call loadUI-cmd.bat "-DmyCustomEndpoint=http://foo.bar"-p project1.xml -r c:\reports -F PDF
call loadUI-cmd.bat "-DmyCustomEndpoint=http://twitter.com/eviware" -p testSLA1.xml
REM Add more endpoints/configurations as needed...
Note that myCustomEndpoint is an arbitrary named variable that we happen to set to an endpoint/URL. You can actually call variables anything and set them to anything, e.g. -DnumberOfCustomers=4711.
You can also set parameters by editing the file called system.properties.
You might also be interested in Parameterizing Scenarios and Data Driven Testing.