0
votes

I use Azure DevOps Test Plans and Test Suites to execute automated tests in a YAML build pipeline. For each release I create a new Test Plan with new Test Suites. Actual I search manually for IDs of Test Plan and Test Suites and copy them to the YAML file.

- task: VSTest@2
  displayName: 'Run automated UI tests'
  inputs:
   testSelector: testPlan
   testPlan: 585
   testSuite: 586,929,930,680,683,684,685,931,681,686,687,688,767,682,689,690,691,768,692
   testConfiguration: 2
   uiTests: true
   testRunTitle: 'Automated UI testing'

Is there a possibility to do that automatically? Or a possibility to reduce the manual effort e.g. just change the Test Plan ID in Pipeline and all Test Suites are automatically included?

2
Not get your latest information, is the below answer helpful for you? Or if you have any concern, feel free to share it here.user13142267
No sorry, I tried to change the YAML file by a CmdLine@2 task before. But it seems that when the pipeline was started, changes in the YAML file doesn’t have any effect.mkr
@mkr How about using rest api in a powershell task? You can view my answer to see if it is helpful to you.Hugh Lin

2 Answers

0
votes

The YAML file is in your repository. So you can edit this file through REST API. Here is an example: Update a file. In this case, you may have some template of your YAML file, identify Test Plan ID and Test Suites (Get a test suites for plan), then update the YAML file with new IDs.

0
votes

Is there a possibility to do that automatically? Or a possibility to reduce the manual effort e.g. just change the Test Plan ID in Pipeline and all Test Suites are automatically included?

You can get the test suites for the test plan through the script in a Powershell task, and then assign the obtained result to a variable.

Use Test Suites - Get Test Suites For Plan rest api:

GET https://dev.azure.com/{organization}/{project}/_apis/testplan/Plans/{planId}/suites?api-version=6.0-preview.1

Sample script:

$url = 'https://dev.azure.com/{organization}/{project}/_apis/testplan/Plans/{planId}/suites?api-version=6.0-preview.1';

$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"} -Method Get

$testSuites = $response

Write-Host "results = $($testSuites | ConvertTo-Json -Depth 100)"

In VSTest task:

- task: VSTest@2
  displayName: 'Run automated UI tests'
  inputs:
   testSelector: testPlan
   testPlan: 585
   testSuite: $(testSuites)
   testConfiguration: 2
   uiTests: true
   testRunTitle: 'Automated UI testing'