Running from the Command Line
- You can have one or more instances of Eggplant Functional running tests from the command line while you continue to develop and run scripts in GUI mode.
- You can add a command-line call to Eggplant Functional at the end of a product build script to perform a smoke test of the new build.
- You can use Windows Scheduled Tasks (or Unix crontab or at command on Mac and Linux) to schedule Eggplant Functional scripts to run at specific times.
For tips on when running from the command line is an appropriate approach as opposed to using Eggdrive, see Eggdrive vs. Command Line Execution.
Every instance of Eggplant Functional requires a license. To use Eggplant Functional from the GUI and the command line at the same time, you need at least two licenses.
You can run Eggplant Functional scripts from a command line two ways:
- The runscript command, which runs scripts without launching the Eggplant Functional GUI.
- The Eggplant command, which launches the Eggplant Functional GUI, then runs scripts.
When using the runscript or Eggplant commands, the command might be unable to obtain a license (due to all of the licenses being in use). If there is no license available, the command being run immediately exits and shows an error code 127. For a better experience, pass the -MaxWaitForLicense MAX_SECONDS parameter so that the command continues to query the license server or servers for a license up to the MAX_SECONDS duration (in seconds). If the command being used (runscript or Eggplant) obtains a license within the MAX_SECONDS time frame, it opens normally.
The Runscript Command
The runscript command launches Eggplant Functional from a command line and runs scripts without showing the Eggplant Functional GUI. Execute the runscript command as described here:
- Type the full path and name of the runscript command, followed by a space.
- Type the full path and name of a script to run.
- For each additional script, insert a space and then type the full path and name for each one.
Important: For Mac installations of Eggplant Functional version 18.0 and later, the path to call the runscript command has changed to /Applications/Eggplant.app/Contents/MacOS/runscript. You might need to update tests created in earlier versions of Eggplant Functional to prevent errors. You also can click the Install runscript in /usr/bin/local button in Eggplant > Preferences > Run Preferences to add the runscript command to your user path. This allows runscript to be called from any directory via the command line.
If you're running Eggplant Functional on a Mac and using a version older than 18.0, the runscript command path remains /Applications/Eggplant.app/runscript.
Examples:
Mac
Windows
Linux
Eggplant Functional saves the results of each script run in the Results folder for that script's suite. Then, after all scripts have finished running, Eggplant Functional reports the number of successful scripts as the return value.
The Eggplant Command
The Eggplant command opens the Eggplant Functional GUI from the command line. You can use it to open the application and run scripts, or you can use it to simply open the application.
Examples:
Mac
Windows
Linux
Passing Parameters to a Script
Eggplant Functional supports the passing of parameters to scripts even when you run them from a command line. You can pass a single parameter, multiple parameters, parameter and value pairs for multiple parameters, and even lists. Parameter values are passed as text strings to the script immediately preceding them. Keep this in mind if you are running multiple scripts in a command.
To pass parameters to a script, you need to precede the parameter values with the -param argument. See -param for information about when to use this argument and examples of how to use it.
- The parameters term refers to what you pass to your scripts.
- The parameter values term refers to the values you are passing for the parameters to your scripts.
- The arguments term refers to the options you pass to the runscript or EggPlant commands. For example, -param is an argument. See Command Line Options for a list of these arguments.
Passing Parameters to Scripts in a Schedule
If you are running a schedule from a command line, the parameters you specify after the suite are passed to each script that is run in the schedule.
How to Pass the Parameters
Following are the syntax and rules for using -param to pass parameter values to scripts at the command line:
- Provide the runscript or Eggplant command first followed by a space, as described in Runscript Command or Eggplant Command above.Note: Whether or not you need to provide the full path to the runscript or Eggplant command, script, or suite depends on which directory you are in when you run the command. On Linux, the Eggplant Functional installer sets variables so that you don't need to provide the path to the runscript or EggPlant commands.
- Specify the script you want to run, followed by a space.
- Provide the -param argument immediately following the script, followed by a space.
- Provide the parameter value you want to pass to the script, enclosed in double quotes. If you need to pass multiple parameters, you must specify the -param argument with each one.
Running Scripts with a Schedule
Eggplant Functional schedules let you collect scripts together that you want to run in a sequence. For more information about schedules, see Running Scripts using Eggplant Functional Schedules.
If you are running a schedule, use the runscript or Eggplant command with the full path to the suite containing the schedule, a slash appropriate for the operating system, and then the schedule name.
Examples:
Mac
Windows
Linux
Running a Table Test
Keyword-driven testing enables you to use keywords to represent functionality you want to test in an external table, along with arguments (data) for each keyword. You can run keyword-driven tests from the command line using the runscript command followed by the path to the table to be executed. For more information about keyword-driven testing, see The Tables Feature and Keyword-Driven Testing.
Examples:
Mac
Windows
Linux
Running Gherkin Features
To run Gherkin tests from the command line, you use the runscript command. This process is essentially the same as it is for running SenseTalk scripts.
Examples:
Mac:
Windows:
In both examples above, following the full path to the runscript command, you enter the full path and name for the .feature file you want to run. You also can include tags as parameters to the runscript command in a -param statement.