Integration with ReadyAPI
Overview
Integrating ReadyAPI into Zephyr allows Zephyr to directly trigger the execution of ReadyAPI Projects. Zephyr will also be able to retrieve test case execution results for visualization within Zephyr.
There are two supported approaches for integration with ReadyAPI, both leveraging Vortex:
Approach 1 allows triggering ReadyAPI projects directly from Zephyr Enterprise, which then parses the generated JUnit XML file to update the test case execution results.
Approach 2 involves using the CI/CD pipeline, which needs to be set up and triggered separately in the CI/CD pipeline as a post-build.
The table below outlines the pros and cons of each approach:
Approach | Pros | Cons |
---|---|---|
1 - Triggering ReadyAPI Directly |
|
|
2 - Leveraging CI/CD Pipeline to trigger the script |
|
|
Triggering ReadyAPI directly from Zephyr Enterprise
The diagram below gives an overview of this setup:
Setup Process Overview
Install ReadyAPI and create a Shell script or BAT file to trigger the desired project
Install and configure zBot on the same machine as ReadyAPI
Setup an Automation job in Zephyr Enterprise
Step 1 - Install and Configure ReadyAPI
Step 1a - If needed, install ReadyAPI
The Trial is available here: Free Trial | API Testing | ReadyAPI
Product Documentation: ReadyAPI Documentation | ReadyAPI Documentation
Step 1b - Ensure that it can be executed for the desired project
Please make sure you're able to run ReadyAPI and execute the desired project properly.
Step 1c - Generate the Shell Script or BAT file
For this integration to work, Zephyr needs to be able to trigger ReadyAPI. It’s possible to trigger ReadyAPI directly, but it’s advisable to trigger a Shell Script or BAT file instead for the sake of convenience and future editing.
Script
Please create a Shell script file located in the same machine as ReadyAPI with the content below:
testrunner.sh -j -J -f<fullPathForResults>; “-RJUnit-Style HTML Report" -FXML "-EDefault environment" <fullPathToProject>
Where:
<fullPathToProject> is the full path and file name for the ReadyAPI.xml project
<fullPathForResults> is the desired full path and file name for the JUnit XML report (.xml file)
For example:
/Applications/ReadyAPI-3.52.0.app/Contents/Resources/app/bin/testrunner.sh -j -J -f/Users/govind.drolia/Documents/readyAPI/result "-RJUnit-Style HTML Report" -FXML "-EDefault environment" /Users/govind.drolia/Documents/readyAPI/REST-Sample-Project-readyapi-project.xml
We can also get the command directly from the ReadyAPI for more details about the command line follow the document TestRunner | ReadyAPI Documentation.
After creating the Shell script file, please trigger it locally to ensure the ReadyAPI project is executed automatically, and that the JUnit XML results are saved to the expected .xml file.
The approach of using a Shell Script file is particularly useful if we want to perform some cleanup operations, like deleting temporary files from the automation run, closing the Browser, or closing down.
Note
Same as Above we can generate the .bat file
Step 2 - Install and Configure ZBot
ZBot is an agent for Zephyr Enterprise that runs on the same machine as the target test automation tool and communicates with Zephyr Enterprise to receive jobs and post results. You may read more about it here: ZBot Overview.
Please follow the instructions below to install the ZBot on the local machine Installing and Getting Started with ZBots.
Step 3 - Setup Vortex Automation
Setup Vortex (including ZBot) using the steps mentioned here for “How to Add and Execute Automation Job”: Zephyr Vortex.
Please see below the final Vortex configuration:
Leveraging the CI/CD Pipeline without ZBOT
Steps for setting up the CI/CD Pipeline
Setup CI/CD pipeline using the steps mentioned here:-
In this, we are using the API to publish the result directly to Zephyr. The API used is API Operations for Automation Jobs | Create and execute a job for this user can use this API in their CI/CD pipeline as a post-build action.
Here is what the shell script for the post-build should look like:
#!/bin/sh /Applications/ReadyAPI-3.52.0.app/Contents/Resources/app/bin/testrunner.sh -j -J -f/Users/govind.drolia/Documents/readyAPI/result "-RJUnit-Style HTML Report" -FXML "-EDefault environment" /Users/govind.drolia/Documents/readyAPI/REST-Sample-Project-readyapi-project.xml zephyrurl=https://qademo.yourzephyr.com Token=ca8f1f49b2d734c3c1bda099a490cc6c0f34340d #endPoint createAndExecute=v4/upload-file/automation/create-and-execute-job #Job Information jobName="RAPI" taskDescription="Update results to Zephyr" automationFramework="SoapUI Pro" projectId=3 releaseId=5 # Cycle info cycleName="ReadyAPI" cycleEndDateStr="09/27/2023" cycleStartDateStr="09/05/2023" isReuse="true" appendDateTimeInCycleName="false" # Folder info phaseName="ReadyAPI" # folder needs to be present beforehand testRepositoryPath="Release 1.0 > ReadyAPI" jobDetailTcrCatalogTreeId=218 assignResultsTo="-10" #timeStamp="false" # Name of the test result file resultPath="@/Users/govind.drolia/Documents/readyAPI/result/report.xml" #payload json="{\"releaseId\":$releaseId,\"jobName\": \"$jobName\",\"automationFramework\": \"$automationFramework\",\"cycleName\": \"$cycleName\",\"jobDetailTcrCatalogTreeId\":$jobDetailTcrCatalogTreeId,\"projectId\":$projectId,\"testRepositoryPath\": \"$testRepositoryPath\",\"cycleEndDateStr\": \"$cycleEndDateStr\",\"cycleStartDateStr\": \"$cycleStartDateStr\",\"isReuse\": $isReuse,\"assignResultsTo\": \"$assignResultsTo\",\"phaseName\": \"$phaseName\"}" echo $json #CreteAnd Execute the job curl -o headers -s -v -i -H "Content-Type: multipart/form-data" -H "Authorization: Bearer $Token" -F "fileName=$resultPath" -F "automationJobDetail=$json" -XPOST $zephyrurl/flex/services/rest/$createAndExecute result="$(cat headers | head -n 1)" echo "Test results: \n" #echo $result # END of the "Create task" code