Skip to main content

QA Sphere CLI Tool: Usage

Installation

Prerequisites

  • Node.js version 18.0.0 or higher

Installation Methods

  1. Via NPM (Recommended)

    npm install -g qas-cli
  2. Via Source Code

    git clone https://github.com/Hypersequent/qas-cli.git
    cd qas-cli
    npm install
    npm run build
    npm link

    Verify the installation:

    qasphere --version

Configuration

The QAS CLI requires authentication token (API key) environment variable to function properly: You can create your API key under the QA Sphere settings.

To do that:

  1. Go to Settings by clicking the gear icon Settings wheel in the top right corner.
  2. Click API Keys
  3. Click Create API Key and generate one wi

Api Key Screenshot You can set these variables in two ways:

  1. Environment Variables: Export them in your shell:

    export QAS_TOKEN=your_token_here
  2. Configuration File: Create a .qaspherecli file in your project directory or any parent directory:

    QAS_TOKEN=your_token_here

Using the junit-upload Command

The junit-upload command is used to upload JUnit XML test results to QA Sphere.

Basic Syntax

qasphere junit-upload -r <run-url> <path-to-junit-xml>

Options

  • -r, --run-url: URL of the QA Sphere test run (required)
  • --attachments: Upload detected attachments with test results
  • --force: Ignore errors and continue uploading

Examples

  1. Upload a single JUnit XML file:

    qasphere junit-upload -r https://qas.eu1.qasphere.com/project/P1/run/23 ./path/to/junit.xml
  2. Upload multiple XML files:

    qasphere junit-upload --run-url https://qas.eu1.qasphere.com/project/P1/run/23 ./*.xml
  3. Upload with attachments:

    qasphere junit-upload -r https://qas.eu1.qasphere.com/project/P1/run/23 --attachments ./junit.xml

JUnit XML Requirements

To ensure successful uploads, your JUnit XML files should follow these naming conventions:

  1. Test case names should contain QA Sphere test case references in the format PROJECT-SEQUENCE.
  2. PROJECT is your QASphere project code.
  3. SEQUENCE is at least a three-digit test case sequence number from the QASphere test case URL.

Examples of valid test case names:

  • PRJ-312: Login with valid credentials
  • Login with valid credentials: PRJ-312

Troubleshooting

  1. If you encounter permission errors, try:

    chmod +x ./build/bin/qasphere.js
  2. For help with any command, use the -h flag:

    qasphere junit-upload -h
  3. Ensure your JUnit XML contains matching test cases to avoid upload errors.

By following these guidelines, you can effectively use the QAS CLI tool to integrate your automated test results with QA Sphere, streamlining your test management process.