Running Tests from the CLI

Learn how to use the CLI to execute individual tests, run groups, and features.

Installing the CLI

With Rainforest’s Command Line Interface (CLI) tool, you can start a test without the need to log into Rainforest directly. Follow these steps to enable the CLI:

  1. Install the CLI. For more information, see How to Install the CLI.
  2. In your Rainforest account, navigate to the Integrations page under Settings to retrieve your API token. Note that the token is unique for each user in your team’s account.

CLI Authentication

For local usage, authentication to the CLI can be done using the --token command line flag, or the RAINFOREST_API_TOKEN environment variable. For example, the following two invocations are equivalent:

# Explicitly pass in the api token:
rainforest run <test_id> --token <token>

# Use the api token specified in the environment variable
export RAINFOREST_API_TOKEN=<token>
rainforest run <test_id>

Note: For use in your CI tool you’ll want to use your service’s dedicated environment variables functionality (e.g. CircleCI users, and for GH Actions users, etc)

How to Start an Individual Test from the CLI

The CLI uses default configuration when running a single test. To update these parameters you can do so via the API.
Note: The default execution method for certain accounts is the human Tester Community. If you want to run your test via automation, ensure you specify execution method as --execution-method automation.

  1. Determine your desired execution method, either automation, crowd, automation_and_crowd, or on_premise.
  2. Open a command or terminal window.
  3. Use the following command, replacing the API token and test ID with the ones from your own account:
rainforest run <test_id> --token <token> --execution-method automation

How to Start Run Groups from the CLI

The CLI uses the configuration defined in the Run Group settings (environment, browsers, execution method, location) unless different parameters are passed. Verify your Run Groups execution method setting is set to how you would like the tests to run, either automation or crowd.

  1. Open a command or terminal window.
  2. To get a list of your run groups and their IDs, use the following command:
rainforest run-groups --token <token>
  1. Once you have noted the IDs of the run group you want to start, use the following command to execute the run group:
rainforest run --run-group <run_group_id> --token <token>
  1. Optionally, set the parameters --environment-id, --browsers, and --execution-method if you want to use different settings for the run.

How to Run a Feature from the CLI

  1. Open a command or terminal window.
  2. Get a list of your features and their IDs using the following command:
rainforest features --token <token>
  1. Once you have the ID of the feature which you want to run, use the following command to start all tests included in the feature:
rainforest run --feature <feature_id> --token <token>

How to Run All Tests from the CLI

Note: The default execution method may be --execution-method crowd. If you want to run your test via automation, ensure you specify execution method as --execution-method automation.

  1. Open a command or terminal window.
  2. Use the following command to start all tests in your Rainforest account:
rainforest run all --token <token> --execution-method automation

👍

CLI Reference

For more information on CLI commands and their usage, see our GitHub page.


If you have any questions, reach out to us at [email protected].