Test Automation

Warning

We strongly discourage and do not endorse using private APIs to manipulate the application's data.

The following points should be noted:

  • Non-Endorsement: We explicitly do not support or endorse using private APIs for any purpose.

  • API Changes: Please be aware that our private APIs may be modified, updated, or deprecated without prior notice. Any reliance on these APIs is done at your own risk.

  • Data Responsibility: Our team is not responsible for any issues related to application data that has been altered, manipulated, or created using private APIs. This includes but is not limited to data loss and data corruption.

It is essential to adhere to our terms of service and official public APIs for a stable and secure application experience. Unauthorized use of private APIs may lead to application instability and data loss. Please consider these factors before using private APIs for any purpose.

Automated testing has become an essential part of the testing process, freeing up time for the team and reducing the rate of errors that occur in manual testing. Coding automated tests that run locally or during builds using continuous-integration (CI) tools gives you a quick and standardized understanding of whether your code is safe to release. This is why we have invested effort to improve our integrations with CI tools such as Jenkins and Bamboo and automated testing in general.

Zephyr Scale offers a range of features that simplify the integration process. We provide a plugin for Jenkins that allows you to both pull BDD test cases from Jira and report the results back to Jira. Our full-featured REST API can be used for a more custom approach. We currently support Cucumber and JUnit tests.

Using these features and functionalities removes the need to create custom scripts to post data to Zephyr Scale and makes the process much simpler. The sections below offer workflow examples for the development project, CI server, and Zephyr Scale.

REST API endpoints

Whichever tool you use for automated testing, we have a public REST API with an extensive set of endpoints that can be used to create custom scripts and enable full integration.

The following image demonstrates the flow of actions from your CI tool, which outputs the results from automated tests as part of a build. Data is pulled from a results file, manipulated if necessary, and then pushed to Zephyr Scale.

rest-api-and-test-automation-01.png

Sample script: create a test cycle with test executions

The script below provides an example of creating a test cycle (and then test executions as part of this cycle) in Zephyr Scale, using the REST API.

// JavaScript / Node.js
// Create a test cycle with test executions.
// The test execution results could have come from an automated test tool, for example.

const fetch = require('node-fetch');

class TestExecutionCreator {
    constructor(jiraSettings, executionResults, projectKey) {
      this._jiraSettings = jiraSettings;
      this._executionResults = executionResults;
      this._projectKey = projectKey;
      this._authString = 'Basic ' + Buffer.from(this._jiraSettings.user + ':' + this._jiraSettings.password).toString('base64');
}

    async createExecutions() {
        const request = this._buildRequest({
            name: 'Automated test executions',
            projectKey: this._projectKey,
            items: this._executionResults
        });
        const url = encodeURI(this._jiraSettings.url + '/rest/atm/1.0/testrun');
        const response = await fetch(url, request); +
        if(response.status !== 201) throw 'Error creating test cycle.';
        const jsonResponse = await response.json(); +
        console.log('Test cycle created:' + jsonResponse.key);
    }

    _buildRequest(body) {
        return {
            method: 'POST',
            body: JSON.stringify(body),
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
                'Authorization': this._authString
            }
        };
    }
}

async function run() {
// Your settings
const settings = {
  'url': '<<your-jira-url>>',
  'user': '<<your-user>>',
  'password': '<<your-password>>'
};
const projectKey = '<<A project key e.g. PROJ>>';

    // These test results could have been generated by an automated test tool
    const executionResults = [{
            'testCaseKey': '<<A test case key>>',
            'status': 'Pass',
            'environment': 'Firefox',
            'executionTime': 180000,
            'executionDate': '2018-12-13T15:22:00-0300',
        }, {
            'testCaseKey': '<<A test case key>>',
            'status': 'Fail',
            'environment': 'Chrome',
            'executionTime': 365000,
            'executionDate': '2018-12-13T18:11:00-0300',
        }, {
            'testCaseKey': '<<A test case key>>',
            'status': 'Pass'
        }, {
            'testCaseKey': '<<A test case key>>',
            'status': 'Fail'
        }];

    await new TestExecutionCreator(settings, executionResults, projectKey).createExecutions();
}

run();
Publication date: