1

We are using the Azure DevOps Test Plan module for our manual testing. We have a Test Plan, under which, we have Test Suite, under which we have Test Cases that are assigned to different Testers. Testers use ADO to mark a Test Case outcome as passed or fail.

We want to download the Test Case outcome/results, but I don't see that option. We have a Test Run tab under Test Plan which shows all Run outcomes but doesn't give the option to download.

Hamza
  • 19
  • 3
Shubham Gupta
  • 369
  • 1
  • 4
  • 15

3 Answers3

1

I am afraid that there is no out-of-box method can directly export the test results of test runs to excel.

To meet your requirement, you can use Rest API to list all required test runs and test results. Then you can export them to Excel.

You can use the following two Rest APIs:

Get Test Runs: Runs - Query

GET https://dev.azure.com/{organization}/{project}/_apis/test/runs?minLastUpdatedDate={minLastUpdatedDate}&maxLastUpdatedDate={maxLastUpdatedDate}&state={state}&planIds={planIds}&isAutomated={isAutomated}&publishContext={publishContext}&buildIds={buildIds}&buildDefIds={buildDefIds}&branchName={branchName}&releaseIds={releaseIds}&releaseDefIds={releaseDefIds}&releaseEnvIds={releaseEnvIds}&releaseEnvDefIds={releaseEnvDefIds}&runTitle={runTitle}&$top={$top}&continuationToken={continuationToken}&api-version=7.0

Get Test Results: Results - List

GET https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/results?detailsToInclude={detailsToInclude}&$skip={$skip}&$top={$top}&outcomes={outcomes}&api-version=7.0

Here is PowerShell sample:

$token = "PAT"

$url=" https://dev.azure.com/orgname/projectname/_apis/test/runs?api-version=7.0"

$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))

$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json

echo $response

ForEach( $testrunid in $response.value.id ) 
{
  echo $testrunid
  $url1 ="https://dev.azure.com/orgname/projectname/_apis/test/Runs/$($testrunid)/results?api-version=7.0"
  $response1 = Invoke-RestMethod -Uri $url1 -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json
  
  ForEach( $testresult in $response1.value) 
  {
     $outcome = $testresult.outcome
     $startedDate = $testresult.startedDate
     $testCase =$testresult.testCase.name
     $completedDate = $testresult.completedDate
     $testCaseTitle = $testresult.testCaseTitle
     echo $outcome
     echo $startedDate
     $Output = New-Object -TypeName PSObject -Property @{
    outcome = $outcome
    runid =$testrunid
    startedDate = $startedDate
    completedDate= $completedDate
    testCase = $testCase 
    testCaseTitle = $testCaseTitle
   } | Select-Object runid, outcome,startedDate,testCase,testCaseTitle,completedDate
$Output | Export-Csv C:\testresult.csv -Append

  }
   
}

You can customize the output excel column according to your requirements.

Result:

enter image description here

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28
  • 1
    Thanks, but sad that such basic feature is not there out of the box, I however found a workaround to download it from the UI itself. – Shubham Gupta Dec 09 '22 at 06:03
  • @ShubhamGupta. Can you share your workaround to download the result? – Kevin Lu-MSFT Dec 09 '22 at 06:06
  • Below are the steps to download the Test Run results from ADO – 1) Navigate to Test Plan -> Runs 2) Click on filters, remove all filters and run the query 3) Click on one result and press Ctrl + A and then Ctrl + C 4) Paste the content in Notepad++, then copy the content from Notepad++ and paste it Excel. 5) This will give you list of all Test Runs with results. You can get the latest outcome of test run, by sorting data using Run ID in descending order and then using unique rows only. – Shubham Gupta Dec 09 '22 at 11:10
0

You could Export the test plan properties, test suite properties along with details of the test cases and test points as either an email or print to pdf by using the Export function of the test suite: doc

Make sure you have test access and permission in Azure DevOps.

enter image description here

enter image description here

enter image description here

Kim Xu-MSFT
  • 1,819
  • 1
  • 2
  • 4
  • Thanks, but this just exports in a printable format. I was looking for a query based format or an excel format, which I can use to build my report on. Any help? – Shubham Gupta Dec 05 '22 at 06:42
0

Below are the steps to download the Test Run results from ADO –

  1. Navigate to Test Plan -> Runs

  2. Click on filters, remove all filters and run the query

  3. Click on one result and press Ctrl + A and then Ctrl + C

  4. Paste the content in Notepad++, then copy the content from Notepad++ and paste it Excel.

  5. This will give you list of all Test Runs with results. You can get the latest outcome of test run, by sorting data using Run ID in descending order and then using unique rows only.

Shubham Gupta
  • 369
  • 1
  • 4
  • 15