Blogs Banner
How to update Selenium test results in Azure DevOps?

How to update Selenium test results in Azure DevOps?

20th Nov, 2019

Following from my previous post, this blog describes the approach and solution to update test results in Azure DevOps after triggering Selenium tests as part of your CI /CD pipeline. For pipeline creation and triggering the test, please refer to the previous blog.


Test results can be updated in Azure DevOps using Web APIs released by Microsoft.


The following is an approach to manage and update test results in Azure from Selenium scripts

  • Collecting the test results: Test Results with Test Case ID, Outcome and Status need to be collected for updating the results in Azure. If you are using Nunit, create a list with test run results and call the relevant update results function inside OneTime TearDown to update the test results
  • An update results function can be called during the OneTimeTearDown to update results in Azure DevOps
  • Configuration file can be used to store details like Project plan, suite and PAT (Personal Access Token for connecting with Azure)


I would like to elaborate more regarding the second point, which can be found below:

Azure Web APIs released by Microsoft can be used to create test runs and update the results. Results can be accumulated as part of a test run and can be parametrized to pass into the test results update function. The expectation is that the test results with Test Case ID, Test Plan ID and Test Suite ID should be collected as part of a test run.


To obtain Test Plan ID and Test Suite ID


If you navigate to test suite in Azure DevOps via browser, the URL contains the test plan and test suite IDs.




Test case ID can be obtained if you navigate to the relevant test case. Once these details are available, follow the below steps:


1. We have to find the test point IDs. The following will help us to find the test point ID


GetPointsAsync (Guid project, int planId, int suiteId, string witFields = null, string configurationId = null, string testCaseId = null, string testPointIds = null, Nullable<bool> includePointDetails = null, Nullable<int> skip = null, Nullable<int> top = null, object userState = null, System.Threading.CancellationToken cancellationToken = null);


2. Next step is to create a run model


RunCreateModel([string name =””], [string iteration =””], [int[] pointIds=null], [ShallowReference Plan=null])


4. Create a test run with the run model created in the previous step


CreateTestRunAsync(RunCreateModel, Guid, Object, CancellationToken)


5. Now we have to get the test results stored after a test run and pass this to the update results API. To achieve this, test results can be stored inside the TestCaseResult (). Example is below:


TestCaseResult CResult = new TestCaseResult() { State = “state”, Outcome = “outcome”, Id = “testcase” };


6. Test results can be updated to the test run


UpdateTestResultsAsync(new TestCaseResult[] { CResult }, ProjectName, TestRunID)


TestRunID can be found from the instance of test run previously created.


Once this is executed, the user should be able to view the test run created with test results in Azure DevOps (Test Plans>Runs)

About the author

Vishnu Vijayakumar | Senior Consultant

The author is experienced in automation testing using tools like Selenium, Appium, TestComplete and UFT. He is also experienced in DevOps with extensive knowledge in domains like Banking, E-Commerce & Cloud Services. His prime focus is now in leading the  developing solutions for the research and development team.