Azure is a Microsoft product that helps in code build, deployment, and testing and also helps managing applications and services through MS data centers.
TABLE OF CONTENTS
Prerequisite Data for Integration
API key for Azure
Testsigma lets you generate your API key in a couple of Steps. You just need to login to your account, navigate to Configuration > API keys, and then click on Create a New API Key button to generate a new API key.
Test Plan ID
We can get the Test Plan ID by clicking on one of the Test Plan names to open the Test Plan details, and then clicking on the CI-CD integration tab. You will find the execution ID for the Test Plan within the REST API Call body content as shown in below screenshot.
Steps to integrate with Azure DevOps
Step 1: Create/Select a Pipeline
Once you are logged in to Azure DevOps account and created a Project, you can click on the Pipeline section and the below image will be displayed. If you want to create a new pipeline, we need to click on the New Pipeline Button to get started.
Step 2: Select the Version Control System(VCS)
After clicking on the New Pipeline button, the below page will be displayed where you need to integrate with the version control system(VCS) such as Git Hub, Bitbucket e.t.c where your Application code is stored.
NOTE: In order to integrate with Azure, you need to have a YAML file in your Code repository. This file contains the details for the CI/CD Integration with Azure DevOps. If not available yet, Azure has an option in which it will create a sample YAML file in your repository once the access is given.
Step 3: Select the Repository
Once you have selected the VCS, it would take you to a page where it will ask you to choose the repository where your Configuration YAML file is present.
Once you select your repository it would take you to the configuration page where you can configure your pipeline.
Step 4: Select Configuration
If you already have your YAML file in your repo, you can select the option Existing Azure Pipeline YAML file.
Else, you can select Starter Pipeline to create a sample YAML file in the selected repository.
In this case, we already had an existing YAML file in the repo. So, once you select the fourth option in the above image, it would take you to a place where you need to enter the branch and path of the YAML file in your repository,
Step 5: Review the CI Configuration
After selecting the Branch and path you can click on "continue" and you will be navigated to the final step where you need to review your YAML code.
The YAML file contains the following code where you need to enter the filePath of the Generic Shell Script (cicd-api.sh)to run it. This Shell script is the one that actually triggers the Test Plan execution and gives you the result of execution once it's complete.
# Starter pipeline # Start with a minimal pipeline that you can customize to build and deploy your code. # Add steps that build, run tests, deploy, and more: # https://aka.ms/yaml trigger:- master pool: vmImage: 'ubuntu-latest' steps:- script: echo Hello, world! displayName: 'Run a one-line script' //Settings - task: Bash@3 inputs: filePath: './cicd-api.sh' //Generic Shell Script file //Settings - task: PublishTestResults@2 displayName: 'publish testsigma test results' inputs: testResultsFormat: 'Junit'// Test Result Format testResultsFiles: '**/junit-report.xml' //Result File Type
In order to Trigger any particular test plan, you just need to add your own Test plan Execution id and the API key in the Shell Script(cicd-api.sh). As shown below:
Please check the below article to get insight on the configuration of Generic Shell Script:
Generic Shell Script for Integrating with any CI/CD Tool
Step 6: Test the Configuration
Once the Script is set up and Reviewed for the pipeline, you can click on the Run button to start your Job.
Once the Run is initiated, you would be navigated to the below page :
Once the Job has completed the Job status would be "Success" as shown in the image below:
Step 7: Checking the Test Run Results
That was all about the Running the Job, now we would learn how can we see the result reports in Azure. Once the job is completed we can see the JUnit report in the Test Plans > Runs as shown below:
After clicking on Runs you can select the execution for which you want to view the report and then you would be navigated to the page below, and also you can download the JUnit report in XML format.
You can use another shell script to convert the JUnit XML format result into an HTML format. A tool like Allure can help you with this.
Welcome to the era of #SmartTestAutomation
***