Skip to main content

How can I run Squish from the command-line interface?

Are you interested in scheduling your test suite or scripts to run? Or want to execute your scripts from the command-line interface (CLI)? Continue reading to find out more.

Introduction

While scripts can be run unattended using 3rd-party integrations, they can also be executed using Squish's CLI.
To record or execute your tests from the CLI, you'll need to know the following:

  1. squishrunner location (default location: <SQUISH_PACKAGE>/bin)
  2. Test suite path
  3. Optional: squishserver location and IP address (if different than squishrunner)
  4. Optional: Test Center base URL, project name and upload token

For the squishrunner to communicate with the squishserver, the squishserver must be running.

There are two ways to start a squishserver.

  1. Start squishrunner with the argument --local to start a local squishserver together with squishrunner.
  2. Provide arguments for the host (--host) and port (--port) to connect to a remote squishserver. If squishserver is on a separate machine than squishrunner, a squishserverrc file must exist specifying allowed hosts, or the same hosts connecting from other locations (more information).

Start squishrunner and squishserver together

Example 1

Instruct squishrunner to run a test suite and start a local squishserver by executing the following command from <SQUISH_PACKAGE>/bin:

  1. Linux and macOS
    ./squishrunner --testsuite "path to the test suite" --local
  2. Windows
    squishrunner.exe --testsuite "path to the test suite" --local

Start squishrunner and squishserver separately

Example 2

Execute the following command from <SQUISH_PACKAGE>/bin:

  1. Linux and macOS
    ./squishserver
  2. Windows
    squishserver.exe

Note: The default, or first available Squish port, 4322, will be used.

Instruct squishrunner to run a test suite using the running squishserver by executing the following command from <SQUISH_PACKAGE>/bin:

  1. Linux and macOS
    ./squishrunner \
    --host "hostname or IP of your Squish server" \
    --port "port of your Squish server" \
    --testsuite "path to the test suite"
  2. Windows
    squishrunner.exe ^
    --host "hostname or IP of your Squish server" ^
    --port "port of your Squish server" ^
    --testsuite "path to the test suite"

     

Note: The --port parameter can be omitted when default port is used.

Start squishrunner and export results to Test Center with a script

NOTE: Both examples expect a running Squish server and a running Test Center with a project and an upload token. See the examples above on how to run the Squish server. You can read at Test Center Setup and Uploading Test Results via Command Line how to get started with Test Center.

Example 3
Wish to create something simple you can reuse and easily modify to point to different squishrunner, squishserver and test suite combinations? How about uploading test results to Test Center?

Try creating a Bash shell or Windows Batch script:

3a: Simple Bash Shell Script for Linux and macOS

#!/usr/bin/env bash

TEST_SUITE="full path to your test suite"

# Squish
SQUISH_PATH="full path to your Squish installation"
SQUISH_SERVER_HOST="hostname or IP of your Squish server"
SQUISH_SERVER_PORT="port of your Squish server"

# Test Center
TEST_CENTER_BASE_URL="the base URL of your Test Center"
TEST_CENTER_PROJECT_NAME="the name of the Test Center project"
TEST_CENTER_UPLOAD_TOKEN="upload token of Test Center"

${SQUISH_PATH}/bin/squishrunner \
--host ${SQUISH_SERVER_HOST} \
--port ${SQUISH_SERVER_PORT} \
--testsuite ${TEST_SUITE} \
--reportgen testcenter,${TEST_CENTER_BASE_URL}/project/${TEST_CENTER_PROJECT_NAME}?token=${TEST_CENTER_UPLOAD_TOKEN}

 

3b: Simple Windows Batch Script

@echo off

set TEST_SUITE="full path to your test suite"

:: Squish
set SQUISH_PATH="full path to your Squish installation"
set SQUISH_SERVER_HOST="hostname or IP of your Squish server"
set SQUISH_SERVER_PORT="port of your Squish server"

:: Test Center
set TEST_CENTER_BASE_URL="the base URL of your Test Center"
set TEST_CENTER_PROJECT_NAME="the name of the Test Center project"
set TEST_CENTER_UPLOAD_TOKEN="upload token of Test Center"

%SQUISH_PATH%\bin\squishrunner.exe ^
    --host %SQUISH_SERVER_HOST% ^
    --port %SQUISH_SERVER_PORT% ^
    --testsuite %TEST_SUITE% ^
    --reportgen testcenter,%TEST_CENTER_BASE_URL%/project/%TEST_CENTER_PROJECT_NAME%?token=%TEST_CENTER_UPLOAD_TOKEN%

Detailed reference to command-line interface:
squishrunner
squishserver

To learn more about the usage of CLI interface, refer to our documentation about Automated Batch Testing, our How-To Article How to Do Automated Batch Testing and one of our Blog Articles Command-line Tools For Image Comparisons.

Comments

    The Qt Company acquired froglogic GmbH in order to bring the functionality of their market-leading automated testing suite of tools to our comprehensive quality assurance offering.