QA Sphere CLI Tool: Usage
Installation
Prerequisites
- Node.js version 18.0.0 or higher
Installation Methods
-
Via NPM (Recommended)
npm install -g qas-cli
-
Via Source Code
git clone https://github.com/Hypersequent/qas-cli.git
cd qas-cli
npm install
npm run build
npm linkVerify 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:
- Go to Settings by clicking the gear icon in the top right corner.
- Click API Keys
- Click Create API Key and generate one wi
You can set these variables in two ways:
-
Environment Variables: Export them in your shell:
export QAS_TOKEN=your_token_here
-
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
-
Upload a single JUnit XML file:
qasphere junit-upload -r https://qas.eu1.qasphere.com/project/P1/run/23 ./path/to/junit.xml
-
Upload multiple XML files:
qasphere junit-upload --run-url https://qas.eu1.qasphere.com/project/P1/run/23 ./*.xml
-
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:
- Test case names should contain QA Sphere test case references in the format
PROJECT-SEQUENCE
. PROJECT
is your QASphere project code.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
-
If you encounter permission errors, try:
chmod +x ./build/bin/qasphere.js
-
For help with any command, use the
-h
flag:qasphere junit-upload -h
-
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.