Share via

How can I get a list of Run ID for a test plan

Benjamin Slack 0 Reputation points
2026-03-09T15:52:28.0433333+00:00

As part of one test plan we are looking for a full list of all the run ID's, test execution date and the test outcome of all the tests executed in that test plan

Azure DevOps

2 answers

Sort by: Most helpful
  1. Rakesh Mishra 8,585 Reputation points Microsoft External Staff Moderator
    2026-03-09T17:38:08.92+00:00

    Hi @Benjamin Slack,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    You can get all run IDs, test case IDs, execution dates, and outcomes for a test plan using either the Azure DevOps Test Management REST API (good for scripting/exports) or the Analytics OData endpoint (better for dashboards and Power BI). Both approaches are covered below.

    Approach 1 – REST API (PowerShell / scripting)

    Step 1 – Get all runs for your test plan

    GET https://dev.azure.com/{organization}/{project}/_apis/test/runs?planId={planId}&api-version=7.1
    

    Each item in the response includes the run's id, name, state, and completedDate.

    Step 2 – Get results for each run

    GET https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/results?api-version=7.1
    

    Each result includes:

    • testCase.id – the test case ID
    • outcome – Passed, Failed, Blocked, etc.
    • startedDate / completedDate – execution timestamps

    Pagination note: This endpoint returns a maximum of 100 results per call. Use $top and $skip to page through all records if any run contains more than 100 results — otherwise data will be silently truncated.

    PowerShell Script (with pagination)

    # Variables
    $org        = "https://dev.azure.com/yourOrg"
    $project    = "yourProject"
    $planId     = 42
    $pat        = "YOUR_PERSONAL_ACCESS_TOKEN"
    $base64Auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat"))
    $headers    = @{ Authorization = "Basic $base64Auth" }
    
    # Step 1 – Get all runs for the plan
    $runsUrl = "$org/$project/_apis/test/runs?planId=$planId&api-version=7.1"
    $runs    = (Invoke-RestMethod -Uri $runsUrl -Headers $headers).value
    
    # Step 2 – Get results per run (with pagination)
    $allResults = foreach ($run in $runs) {
        $skip = 0; $top = 100
        do {
            $url   = "$org/$project/_apis/test/Runs/$($run.id)/results?`$top=$top&`$skip=$skip&api-version=7.1"
            $batch = (Invoke-RestMethod -Uri $url -Headers $headers).value
            foreach ($res in $batch) {
                [PSCustomObject]@{
                    RunId         = $run.id
                    RunName       = $run.name
                    TestCaseId    = $res.testCase.id
                    Outcome       = $res.outcome
                    StartedDate   = $res.startedDate
                    CompletedDate = $res.completedDate
                }
            }
            $skip += $top
        } while ($batch.Count -eq $top)
    }
    
    # Step 3 – Export to CSV
    $allResults | Export-Csv -Path ".\TestPlan_${planId}_Results.csv" -NoTypeInformation
    
    Approach 2 – Analytics OData (best for Power BI / dashboards)

    If you need this data for ongoing reporting, the Analytics OData endpoint is more efficient. It lets you query all execution history for a test plan in a single request, without looping through each run.

    Note: Analytics for Azure DevOps testing requires v3.0-preview or v4.0-preview of the OData API. The TestResults entity does not expose TestPlanId directly, so there are two ways to approach this depending on your goal.

    Option A – Use TestPointHistorySnapshot (filter directly by TestPlanId)

    This is the simplest approach when you want to filter by plan ID without first looking up run IDs.

    Step 1 – Open your browser or Power BI and call the following URL:

    https://analytics.dev.azure.com/{organization}/{project}/_odata/v4.0-preview/TestPointHistorySnapshot
      ?$filter=TestPlanId eq {planId}
      &$select=TestPlanId,TestCaseId,ResultOutcome
      &$expand=Date($select=Date)
    

    This returns one record per test point execution with:

    • TestCaseId – ID of the test case executed
    • ResultOutcome – Passed, Failed, Blocked, etc.
    • Date – the execution date (expanded from the DateSK navigation property)

    Step 2 – To also include the Run ID, expand the TestRun navigation property:

    https://analytics.dev.azure.com/{organization}/{project}/_odata/v4.0-preview/TestPointHistorySnapshot
      ?$filter=TestPlanId eq {planId}
      &$select=TestPlanId,TestCaseId,ResultOutcome
      &$expand=Date($select=Date),TestRun($select=TestRunId,Title)
    

    Option B – Use TestResults (filter by a list of TestRunIds)

    Use this when you already have your run IDs (e.g. from Step 1 of Approach 1 above) and want the full granular result detail.

    Step 1 – Build your run ID list from the REST API (as shown in Approach 1, Step 1), then use it in the OData filter:

    https://analytics.dev.azure.com/{organization}/{project}/_odata/v4.0-preview/TestResults
      ?$filter=TestRunId in (101, 102, 103)
      &$select=TestRunId,Outcome,StartedDate,CompletedDate
      &$expand=Test($select=TestCaseReferenceId,TestName)
    

    This returns:

    • TestRunId – the run the result belongs to
    • Outcome – Passed, Failed, Inconclusive, etc. (15 possible values)
    • StartedDate / CompletedDate – execution timestamps
    • Test.TestCaseReferenceId – the test case ID
    • Test.TestName – human-readable test name

    Step 2 – Test the query in your browser first. Install a JSON formatter extension (available for Chrome and Edge) to read the output easily before wiring it into Power BI.

    Step 3 – Connect to Power BI. In Power BI Desktop:

    1. Select Get Data → OData feed
    2. Paste the query URL above (converted to a single line)
    3. Authenticate with your Azure DevOps credentials
    4. Expand the Test column to surface TestCaseReferenceId and TestName
    References

    Let me know if this helps in comments.

    Note: This answer is drafted with the help of AI systems.

    Was this answer helpful?

    0 comments No comments

  2. Q&A Assist
    2026-03-09T15:52:43.2+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Use test runs and test results data to retrieve this information.

    1. Get the list of test runs for the test plan
      • Each execution of tests creates a test run with a Test Run Id.
      • In the UI:
        1. Go to Test Plans in the Azure DevOps project.
        2. Select Runs to open the Test Run Hub.
        3. Use filters to scope to the relevant test plan (for example, by timeline, run type, and other attributes). The hub lists all runs, and each row includes the test run ID and state.
        4. Optionally search by a specific test run ID if needed.
    2. Understand what a test run provides
      • A test run is the container for execution of one or more test cases and tracks outcome, duration, and execution details for that session.
      • Test runs can be manual or automated; the Test Run Type field indicates this.
    3. Get execution date and outcome per test
      • At the analytics level, each individual test execution is a TestResult record.
      • Relevant fields:
        • TestRunId: numeric ID of the test run the result belongs to.
        • Outcome: test result outcome (Aborted, Blocked, Error, Failed, Inconclusive, In progress, None, Not applicable, Not executed, Not impacted, Passed, Paused, Timeout, Unspecified, Warning).
        • Navigation properties StartedOn and CompletedOn (via StartedDateSK and CompletedDateSK) give execution timestamps.
      • Use the Test Plans Analytics OData endpoint (or any analytics tooling wired to it) to query TestResults filtered by the test plan’s runs (by TestRunId) and project, and then project the columns:
        • TestRunId
        • Outcome
        • StartedOn / CompletedOn (for execution date/time)
    4. Optional: programmatic access in extensions
      • In extensions using azure-devops-extension-api, CustomTestRunData exposes testPlanId, which can be used to associate runs back to a specific test plan when building custom providers such as TestRunsListDataProvider.

    This combination (Test Run Hub for run IDs and Analytics TestResults for per-test execution date and outcome) provides the full list of run IDs, execution dates, and outcomes for all tests executed in a given test plan.


    References:

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.