Integrate Testsigma with Azure DevOps


Microsoft Azure, aka Azure, is a cloud computing service created by Microsoft for building, testing, deploying, and managing applications and services through Microsoft-managed data centers.


Prerequisites:

  • API key for Azure. For more information, refer to API keys.
  • A Test Plan ID. For more information, refer to get test plan id.

How to integrate with Azure DevOps

  1. Login to the Azure DevOps account and create a Project. Navigate to Pipelines and click on the New Pipeline to get started. create new pipeline azure devops
  2. Choose the Version Control System (VCS) where your application code is stored. select version control system in Azure Devops
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 access is given.

  1. Choose the repository where your Configuration YAML file is present. Once you select your repository it will take you to the configuration page where you can configure your pipeline. select repository in Azure DevOps
  2. On Configure your pipeline page, if you already have your YAML file in your repo, you can select the option Existing Azure Pipeline YAML file. Otherwise, you can select Starter Pipeline to create a sample YAML file in the selected repository. configure your pipeline page in Azure DevOps

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 will take you to a place where you need to enter the branch and path of the YAML file in your repository. Select existing pipeline while configuring an existing YAML file in Azure DevOps

  1. Review the CI Configuration after selecting the Branch and Path, click on Continue. Review CI configuration in Azure DevOps

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 Test plan 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 a 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: shell script for Azure DevOps

For more information on configuration of Generic Shell Script, refer to https://testsigma.com/docs/continuous-integration/shell-script/.

  1. Test the configuration once the script is set up and reviewed for the pipeline, and click on the Run to start your Job. test configuration in Azure DevOps

Once the Run is initiated, you will see this page: set up ci with Azure Pipelines

Once the job has been completed, the Job status will be Success as shown in the image below: Job Status Success in Azure DevOps

  1. Once the job is completed we can see the reports in the Test Plans > Runs. Test Plans Runs in Pipelines in Azure DevOps

After clicking on Runs you can select the Test plan for which you want to view the report and then you will be navigated to the page below, and also you can download the JUnit report in XML format. Junit report in Azure DevOps

You can use another shell script to convert the JUnit XML format result into an HTML format.