コマンドラインからの実行

You can run Eggplant Functional scripts and suites from a 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.

Note: The Ask and Answer commands won't prompt for input when running from the command line. If you intend to run Eggplant Functional script from the command line and have Ask or Answer commands in scripts, you should set default values for the information that would otherwise be obtained from the user.

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:

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. ここで説明する方法で、runscriptコマンドを実行します。

  1. runscriptコマンドのフルパスと名前をタイプし、後にスペースを続けて入力します。
  2. 実行するスクリプトのフルパスと名前を入力します。
  3. 追加のスクリプトそれぞれには、スペースを挿入してそれからそれぞれのフルパスと名前を入力します。

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 from . 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.

例:

Mac (bash shell):

/Applications/Eggplant.app/Contents/MacOS/runscript /Users/Alex/Documents/appTests.suite/Scripts/test1.script /Users/Alex/Documents/appTests.suite/scripts/test2.script

Windows (command shell):

"C:\Program Files\Eggplant\runscript.bat" "C:\Users\Alex\My Documents\MySuite.suite\Scripts\test1.script" "C:\Users\Alex\My Documents\MySuite.suite\Scripts\test2.script"

Linux (bash shell):

runscript ~/Documents/appTests.suite/Scripts/test1.script ~/Documents/appTests.suite/Scripts/test2.script

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.

Note: The Linux installation of Eggplant Functional sets environment variables so you can call the runscript command from any directory by specifying only its name.
Note: To have Eggplant Functional report script successes instead of failures, set the -ReportFailures option to no. コマンドラインオプションについてのさらなる情報は、 Command Line Options(コマンドラインオプション)を参照してください。
Note: The Ask and Answer commands won't prompt for input when running from the command line. このアプローチを使って、スクリプトでAsk(質問) またはAnswer(回答)コマンドを行うには、それ以外の場合ならユーザーから取得する情報にはデフォルト値を設定するべきです。 これらのコマンドを使用するための情報は、User Interaction(ユーザーの相互作用)を参照してください。

The Eggplant Command

The Eggplant command opens the full GUI Eggplant Functional application from a command line. これを使ってGUIアプリケーションをオープンしてスクリプトを実行できますし、または単にアプリケーションをオープンする事もできます。

例:

Mac (bash shell):

/Applications/Eggplant.app/Contents/MacOS/Eggplant

Windows (command shell):

"C:\Program Files\Eggplant\Eggplant.bat"

Linux (bash shell):

Eggplant

Note: The Linux installation of Eggplant Functional sets environment variables so that you can launch the Eggplant GUI application from any directory by specifying only its name.
Note: When you launch the Eggplant Functional GUI from the command line, the standard output is not displayed in the terminal. その代わり、それはログとしてユーザーアカウントのアプリケーションSupport\Eggplantディレクトリに保存されます。

Passing Parameters to a Script

Eggplant Functional supports the passing of parameters to scripts even when you run them from a command line. 単一のパラメータ、複数のパラメータ、複数のパラメータ用のパラメータと値のペア、さらにリストまで渡す事ができます。 パラメータの値は文字列としてスクリプトに、先行して即座に渡されます。 複数のスクリプトをコマンドで実行している場合に、この事を覚えておいてください。

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.

Note: Information in this section uses the following terms when talking about passing parameters.
  • 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.

スケジュールに沿ってパラメータをスクリプトに渡す

コマンドラインからスケジュールを実行する場合は、スイートの後で特定したパラメータはスケジュールに沿って実行される各スクリプトに渡されます。

パラメータの渡し方

Following are the syntax and rules for using -param to pass parameter values to scripts at the command line:

  1. 最初にrunscriptまたはEggplantにスペースを続けて指定します。上記のRunscript Command(Runscriptコマンド)またはEggplant Command(Eggplantコマンド)にて説明している通りです。
    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.
  2. 実行したいスクリプトを指定し、続けてスペースを入力します。
  3. Provide the -param argument immediately following the script, followed by a space.
  4. 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.
Note: If you are running multiple scripts, you must include -param with the appropriate parameter values with each script.
Note: You can also specify parameters before script names as default parameters. If you include any parameters after a script name, those parameters are passed to the script.

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.

スケジュールを実行する場合、runscriptまたはEggplantコマンドをフルパスで、スケジュールとオペレーティングシステムに適合したスラッシュ、それからスケジュール名を含めてスイートに対して使用します。

例:

Mac (bash shell):

/Applications/Eggplant.app/Contents/MacOS/runscript /Users/Sam/appTests.suite/Schedule1

/Applications/Eggplant.app/Contents/MacOS/Eggplant/Eggplant /Users/Sam/appTests.suite/Schedule1

Windows (command shell):

"C:\Program Files\Eggplant\runscript.bat" "C:\Users\Alex\My Documents\MySuite.suite\Schedule1"

"C:\Program Files\Eggplant\Eggplant.bat" "C:\Users\Alex\My Documents\MySuite.suite\Schedule1"

Linux (bash shell):

runscript ~/Documents/appTests.suite/Schedule1

Eggplant ~/Documents/appTests.suite/Schedule1

Note: If you only specify the suite name, this command runs the first schedule in the suite, determined alphabetically. If there are no schedules to run, Eggplant Functional returns a "No Scripts to Run" error. For more information about running scripts with schedules, see Running Scripts using Eggplant Functional Schedules.
Note: Eggplant Functional saves the results of each script run in the Results folder for that script's suite. Then, after all scripts and suites have finished running, Eggplant Functional reports the number of successful scripts and suites as the return value. スイートは、そこに含まれる全スクリプトが成功した場合は、成功とします。
Note: This can be used with the -RunOnLaunch command line option.
Note: You will not see the name of the schedule in a directory listing of the suite.

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. キーワード駆動テストをコマンドラインから、runscriptコマンドを使って実行できます。実行する表へのパスをコマンドに続けます。 For more information about keyword-driven testing, see The Tables Feature and Keyword-Driven Testing.

例:

Mac (bash shell):

/Applications/Eggplant.app/Contents/MacOS/runscript /Users/Greg/Documents/AppTests.suite/TableScripts/TableName.table

Windows (command shell):

"C:\Program Files\Eggplant\runscript.bat" "C:\Users\Alex\nobr>My Documents\AppTests.suite\TableScripts\TableName.table"

Linux (bash shell):

runscript ~/Documents/appTests.suite/TableScripts/TableName.table

 

This topic was last updated on 2月 01, 2019, at 11:13:23 午前.

Eggplant icon Eggplant.io | Documentation Home | User Forums | Support | Copyright © 2019 Eggplant