Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Generating the Junit report from Playwright tests and uploading it to AIO Tests.

  • Generating Cucumber reports with Playwright + Cucumber and uploading it in AIO Tests

  • Using AIO Tests REST APIs to report results and much more, using the Playwright framework hooks.

...

Post execution of a suite, the TEST-<xxx>.xml file can be uploaded either via

...

AIO Tests provides a rich set of APIs for Execution Management, using which users can not only report execution status, but also add effort, actual results, comments, defects and attachments to runs as well as steps.
AIO Tests also provides APIs to create cycles and to add cases to cycles for execution planning.

The basic sample below will show how Mocha Hooks in WebdriverIO can leverage the AIO Tests REST APIs to report results. In the wdio.conf.js, the afterTest method can be used to make AIO API call.

...

For the purpose of the example, we have established a convention to map cases - the AIO Tests case key is the prefix to the case title ege.g. it('NVPROJ-TC-11: should login with valid credentials' contains NVPROJ-TC-11, which is the AIO Tests Case key.

...

Code Block
languagejs
const axios = require('axios');

class AIOReporter {

    promises = [];
    onTestEnd(test, result) {
        this.promises.push(this.postResults(test, result));
    }

    postResults(test, result) {
        if(test.title.startsWith("NVTES-TC-")) {
            let tc = test.title.split(":")[0].trim()
            console.log("Reporting results ..." + tc)
            let resultData = {"testRunStatus": result.status === 'passed'? "Passed" :"Failed", "effort": result.duration/1000};
            if(result.status !== 'passed')
            {
                resultData["comments"] = [result.error];
            }
            return axios({
                method: 'post',
                url: `https://tcms.aioreportsaiojiraaaps.com/aio-tcms/api/v1/project/NVTES/testcycle/NVTES-CY-434/testcase/${tc}/testrun`,
                headers: {'Authorization': 'AioAuth yourtokenhere'},
                data :resultData
            })
                .then(function (response) {
                    console.log(response.data)
                }).catch((e) => console.log(e.response.data));
        }
    }
    
    //On End returns a promise and hence it is important, since onTestEnd is not async
    onEnd(result) {
        return Promise.all(this.promises);
        //On end can also be used to simply import the Junit file in AIO, using the
        //Import results API.  For code sample of Import Results API, please refer 
        //to Reporting results via Cucumber Hooks and AIO Tests REST APIs sample
    }
}

module.exports = AIOReporter;

...

  1. It uses the test title to identify the case key [ based on the convention established]

  2. Create a POST request

    1. URL : For cloud the url host would be https://tcms.aioreportsaiojiraapps.com/aio-tcms/api/v1. For Jira server, it would be the native Jira server hostname.

    2. Authorization : Please refer to /wiki/spaces/ATDoc/pages/1499594753 Rest API Authentication to understand how to authorize users. The authentication information goes in the headers: {'Authorization': '<Auth based on Jira Cloud/Jira Server>'},

    3. POST Body : The body consists of data from the test and result object provided by Playwright. If the case has failed, the error is posted as comments.

    4. If required, the basic example can be extended to upload attachments against the case using the upload attachment API.

Info

The above is a basic example of what can be done with the hooks and AIO Tests APIs. It is recommended to add appropriate error handling and enhance it based on your automation requirements.

...

Post execution of a suite, the cucumber.json file can be uploaded either via

...

AIO Tests provides a rich set of APIs for Execution Management, using which users can not only report execution status, but also add effort, actual results, comments, defects and attachments to runs as well as steps.
AIO Tests also provides APIs to create cycles and to add cases to cycles for execution planning.

The basic sample below will show how Cucumber Hooks can leverage the AIO Tests REST APIs to report results.

...