Running Squish tests with Bitbucket Pipelines

Last edited on

Bitbucket Pipelines are the tool that can be used not only for building but also for testing and deploying applications. The testing part may also include automatic tests created with Squish GUI Tester. The following article describes how this can be achieved. Please note that this is not the only solution but rather one of the options that should give you a general overview of the setup and required components.

Requirements

A proper Squish package is required. For the demo purpose, the squish-6.7.1-qt59x-linux64.run package is used. The Squish package is added to a dedicated Bitbucket repository (squishpackage) in a Squish version-specific branch (s671-qt59-lnx64). That allows simple switching between Squish packages based on the system and the application under test requirements.

Squish package branch
Squish package branch

This repository is pulled into a pipeline created for a different one named SquishTests. This package contains the Pipeline file and Squish test cases.

Squish test suites repository
Squish test suites repository

Pipeline

  1. Get Squish package:
    To allow cloning another please follow this article. Once it's done you can clone the Squish package into the pipeline.

    - git clone --branch s671-qt59-lnx64 git@bitbucket.org:jakubFrog/squishpackage.git
    Clone squishpackage repository

  2. Install Squish:
    Once the package is available in the pipeline it's time to install Squish. For that, the (unattended installation)[https://doc.qt.io/squish/installing-from-binary-packages.html#ins-binary-unattended] is required. The TMPDIR environment variable is set to specify the location of the temporary installation files.

    - mkdir ./tmp
    - export TMPDIR=`pwd`/tmp
    - chmod a+x squishpackage/squish-6.7.1-qt59x-linux64.run
    - squishpackage/squish-6.7.1-qt59x-linux64.run unattended=1 targetdir=`pwd`/squish python=3.8 licensekey=<SQUISH_LICENSE_KEY>
    Unattended Squish installation

  3. Start Xvfb server:
    As Squish requires some kind of a display, the Xvfb server provided within (the default build environment of Bitbucket Pipelines)[https://hub.docker.com/r/atlassian/default-image/] is used.

    - export DISPLAY=:8
    - Xvfb :8 -screen 0 1280x1024x24 &
    Start Xvfb server

  4. Register AUT and execute the tests:
    Before starting the test cases, application under tests needs to be registered. In this example, the example Addressbook application is used.

    - ./squish/bin/squishserver --config addAUT addressbook `pwd`/squish/examples/qt/addressbook/
    - sleep 2
    - ./squish/bin/squishserver &
    - sleep 3
    - ./squish/bin/squishrunner --testsuite ./suite_py --reportgen stdout --reportgen junit,test-results/junit-result.xml --reportgen html,HTML-report
    Register AUT and start test execution

Test Results

In the above example, the test execution generates JUnit and HTML results. After the pipeline build is finished, both can be stored as build artifacts.

Artifacts
Artifacts

On top of that, the JUnit results can be accessed directly via the Tests tab on the build page.

JUnit results
JUnit results

The downloaded HTML report can be used for further result analysis.

Example pipeline file

The below example shows the complete example pipeline that installs Squish and executes tests against the example application and aggregates the test results. It also prepares the environment and installs some required libraries that were not part of the docker image.

image: atlassian/default-image:2

pipelines:
  default:
    - step:
        name: 'Install Squish and run tests'
        artifacts:
          - test-results/junit-result.xml
          - HTML-report/**
        script:
          - apt-get update
          - apt-get -y install libxkbcommon0
          - export SQUISH_LICENSEKEY_DIR=`pwd`
          - export SQUISH_PCKG=squishpackage/squish-6.7.1-qt59x-linux64.run
          - mkdir ./tmp
          - export TMPDIR=`pwd`/tmp
          - mkdir ./tmp/runtime-root
          - export XDG_RUNTIME_DIR=`pwd`/tmp/runtime-root
          - git clone --branch s671-qt59-lnx64 git@bitbucket.org:jakubFrog/squishpackage.git
          - chmod a+x $SQUISH_PCKG
          - $SQUISH_PCKG unattended=1 targetdir=`pwd`/squish python=3.8 licensekey=<SQUISH_LICENSE_KEY>
          - export DISPLAY=:8
          - Xvfb :8 -screen 0 1280x1024x24 &
          - sleep 5
          - ./squish/bin/squishserver --config addAUT addressbook `pwd`/squish/examples/qt/addressbook/
          - sleep 2
          - ./squish/bin/squishserver &
          - sleep 3
          - ./squish/bin/squishrunner --testsuite ./suite_py --reportgen stdout --reportgen junit,test-results/junit-result.xml --reportgen html,HTML-report
Pipeline script