qasectl - Qase CLI tool

qasectl is Qase's command line app build in Go Language, which can be used to start and complete test runs, and it can publish results to Qase in several formats.

View source code on GitHub here: https://github.com/qase-tms/qasectl


How to install the app?


Install via Homebrew (macOS/Linux)

brew tap qase-tms/tap
brew install qasectl

Install via go install

To install Qase CLI is using go install:

go install github.com/qase-tms/qasectl@latest

Make sure to add $GOPATH/bin to your $PATH environment variable to be able to run the qasectl command.

The binary is named qasectl


Build from source

Clone the repository

git clone <https://github.com/qase-tms/qasectl.git> && cd qasectl

Build the binary

make build

You will find the binary in the build/ directory.

Try creating a test run by executing the binary -

./build/qasectl testops run create --project QD --token <your-token> --title "Run created from Qase-cli" --description "Hello, from qase-cli" --environment <env-slug> --verbose

Use a Docker image

Pull the Docker image

docker pull ghcr.io/qase-tms/qase-cli:latest

Run the Docker container

docker run --rm ghcr.io/qase-tms/qase-cli:latest <add-your-command-here>

Using Qase CLI

You can generate an API token from here 🔗 and refer to this guide 🔗 to find your project code, and run_id in Qase.

Create a test run

You can create a test run by using the create command. The create command is used to create a new test run in the specified project and save a test run ID to a file.

You can specify the file path using the --output option.

If the file path is not specified, the test run ID will be saved to qase.env in the current directory.

The file will contain the test run ID in the following format:

QASE_TESTOPS_RUN_ID=123

You can use the test run ID in subsequent steps to upload test results for the test run.

For extracting the test run ID from file, use the following command:

cat qase.env | grep QASE_TESTOPS_RUN_ID | cut -d'=' -f2

Example usage -

qasectl testops run create
  • -p <project_code>
  • -t <token>
  • --title <title>
  • -d <description>
  • -e <environment>
  • -m <milestone>
  • -o <plan>
  • -v

Supported options

Required:

  • --project, -p: The project code where the test run will be created.
  • --token, -t: The API token to authenticate with the Qase API.
  • --title: The name of the test run.

Optional:

  • --description, -d: The description of the test run.
  • --environment, -e: The environment where the test run will be executed.
  • --milestone, -m: The milestone of the test run.
  • --plan: The test plan of the test run.
  • --output, -o: Output path to save the run ID (default is qase.env in working directory).
  • --verbose, -v: Enable verbose mode.

The following example shows how to create a test run in the project with the code DEMO:

qasectl testops run create  
--project DEMO  
--token <token>  
--title "Example test run created using Qase CLI"  
--verbose

Complete a test run

You can complete a test run by using the complete command. The complete command is used to complete a test run in the specified project.

Example usage -

qasectl testops run complete  
--project <project_code>  
--token <token>  
--id <run_id>  
--verbose

Here, the --id flag takes the ID of the Qase test run that is to be marked complete.

The following example shows how to complete a test run with the ID 1 in the project with the code DEMO:

qasectl testops run complete --project DEMO --token <token> --id 1 --verbose

Upload test results

You can upload test results by using the upload command. The upload command is used to upload test results for a test run in the specified project.

Example usage -

qasectl testops result upload  
--project <project_code>  
--token <token>  
--id <run_id>  
--format <format>  
--path <results_file>  
--batch <batch>  
--verbose

Supported options

Required:

  • --project, -p: The project code where the test results will be uploaded.
  • --token, -t: The API token to authenticate with the Qase API.
  • --id: The ID of the test run to upload results for. Required if title is not set.
  • --path: The path to the test results file or folder. For maestro, it is the folder of one run.
  • --format: The format of the test results file. Allowed values: junit, qase, allure, xctest, maestro.

Optional:

  • --description, -d: The description of the test results.
  • --steps: The mode of upload steps for XCTest and Maestro. Allowed values: all, user. For Maestro, all also shows the service commands (defineVariables, applyConfiguration), while user (default) hides them.
  • --batch: The batch number of the test results. Default value is 200.
  • --suite, -s: Define the root suite for all the test results.
  • --replace-statuses, -r: The statuses to replace. Optional. Pass like {\"Passed\": \"Failed\"} to replace all passed results with failed. Note: Use slugs of statuses.
  • --skip-params: Skip parameters for the results.
  • --attachment-extensions: Comma-separated list of file extensions to filter attachments. If not specified, all attachments are uploaded.
  • --verbose, -v: Enable verbose mode.

The following example shows how to upload test results in the JUnit format for a test run with the ID 1 in the project with the code DEMO:

qasectl testops result upload  
--project DEMO  
--token <token>  
--id 1  
--format junit  
--path /path/to/results.xml  
--verbose

Similarly, use the following paths for other result types:

  • Qase format: --path /path/to/build/qase-results/results.json

    • For results generated from qase-pytest , use the path: /path/to/build/qase-results/results/
  • Allure format: --path /path/to/allure-results

  • XCTest format: --path /path/to/xctest-results

  • Maestro format: --path /path/to/maestro-run (see Upload Maestro results below)


Upload Maestro results

📘

Requires qasectl v0.6.0 or later.

The maestro format reads the debug output of a Maestro 2.x run. Maestro 1.x is not supported.

Run the flows so the debug output and the JUnit report are saved to the same folder, then upload that folder:

maestro test --debug-output <run-dir> --flatten-debug-output --format junit --output <run-dir>/report.xml <flows>
qasectl testops result upload --project DEMO --token <token> --id 1 --format maestro --path <run-dir> --verbose

--path is the folder of one run. If it holds several runs, the command fails with an error. The JUnit report is searched for only inside --path, so pass the run folder (not a single flow folder). Without the JUnit report, the device names are not set.


Linking flows to test cases

Each flow becomes one test result, and its commands become steps. Set the Qase attributes in the flow properties. Maestro accepts only string values, so several IDs are written as one comma-separated string:

appId: com.example.app
name: Search products
tags:
  - smoke
properties:
  qase.id: "123, 456"
  qase.suite: "Search.Smoke"
  severity: critical
---
- launchApp
  • qase.id: The IDs of the Qase test cases the result belongs to. The PRJ-123 form is accepted too (the number after the last - is used). Elements that cannot be parsed are skipped with a warning. With several IDs, Qase records a result for each case.
  • qase.suite: The suite of the test case. Levels are separated by a dot.
  • Any other key becomes a result field with the same name. Qase applies it only if the project has a system or custom field with that name. qase.* keys are not sent as fields.
  • The flow tags become the tags of the test case.

Without qase.id, Qase matches the result to a test case by its signature: qase.suite, the flow file name, the flow name and the device parameter. Renaming the flow or running it on another device creates a new test case.


How a flow is reported

  • The result title is the flow name, or the flow file name when name is not set.
  • Steps keep the nesting of runFlow, so a failure inside a subflow is shown on the step where it happened, and its error becomes the result message.
  • A retried command is shown as Attempt N steps, a repeated one as Iteration N steps. The result gets the is_flaky field only when the flow finally passes after a failed retry attempt.
  • A failed optional: true command is a passed step with the comment Optional command failed.
  • A flow that did not finish (Maestro or the device stopped mid-run) is failed with the message Flow did not finish. A flow with an empty or broken commands.json is skipped with a warning.
  • With several shards, the shard number is written as the thread shard-N.
  • The device name from the JUnit report is written to the device parameter. --skip-params drops it.
  • Screenshots Maestro takes on failure and with takeScreenshot are attached to their steps. Screen hierarchy dumps are not uploaded.
  • maestro.log and the device logs are attached only to failed results. Files over 32 MB are gzipped, and a file still over 32 MB after gzip is skipped with a warning. --attachment-extensions matches the gzipped log as gz.

Create Environments and Milestones

Similar to creating test runs, you can use the create command to create a new environment or milestone in the specified project and save a value to a file.

The path for saving the qase.env file can be specified using the --output option.

If the file path is not specified, qase.env will be saved to the working directory.

The qase.env file will contain:

  • QASE_ENVIRONMENT=<slug>
  • or
  • QASE_MILESTONE=<id>

You can use the environment slug or milestone ID in subsequent steps when creating a new test run.

For extracting the values from the file, use the following commands:

cat qase.env | grep QASE_ENVIRONMENT | cut -d'=' -f2
cat qase.env | grep QASE_MILESTONE | cut -d'=' -f2

Create an Environment

Example usage -

qasectl testops env create  
--project <project_code>  
--token <token>  
--title <title>  
--slug <slug>  
--description <description>  
--host <host>  
--verbose

Supported options for env create

Required:

  • --project, -p: The project code where the environment will be created.
  • --token, -t: The API token to authenticate with the Qase API.
  • --title: The title of the environment.
  • --slug: The slug value of the environment.

Optional:

  • --description, -d: The description of the environment.
  • --output, -o: Output path to save qase.env.
  • --verbose, -v: Enable verbose mode.

Create a Milestone

Example usage -

qasectl testops milestone create  
--project <project_code>  
--token <token>  
--title <title>  
--description <description>  
--status <status>  
--due-date <due_date>  
--verbose

Supported options for milestone create

Required:

  • --project, -p: The project code where the milestone will be created.
  • --token, -t: The API token to authenticate with the Qase API.
  • --title: The name of the milestone.

Optional:

  • --description, -d: The description of the milestone.
  • --status, -s: The status of the milestone. Allowed values: active, completed.
  • --due-date, -d: The due date of the milestone. Format: YYYY-MM-DD.
  • --output, -o: Output path to save qase.env.
  • --verbose, -v: Enable verbose mode.

Did this page help you?