|
| 1 | +This tutorial will show you how to work with Azure DevOps (ADO) test cases and test suites using fscps.tools. |
| 2 | + |
| 3 | +## **Prerequisites** |
| 4 | +* PowerShell 5.1 |
| 5 | +* fscps.tools module installed |
| 6 | +* Access to an Azure DevOps project with Test Plans |
| 7 | +* A valid Azure DevOps Personal Access Token (PAT) with test management permissions |
| 8 | + |
| 9 | +Please visit the [Install as a Administrator](https://github.com/fscpscollaborative/fscps.tools/wiki/Tutorial-Install-Administrator) or the [Install as a non-Administrator](https://github.com/fscpscollaborative/fscps.tools/wiki/Tutorial-Install-Non-Administrator) tutorials to learn how to install the tools. |
| 10 | + |
| 11 | +## **Import module** |
| 12 | + |
| 13 | +``` |
| 14 | +Import-Module -Name fscps.tools |
| 15 | +``` |
| 16 | + |
| 17 | +## **Prepare authentication** |
| 18 | + |
| 19 | +All ADO cmdlets require a `-Token` parameter. Use a Bearer token with your PAT: |
| 20 | + |
| 21 | +``` |
| 22 | +$pat = "your-personal-access-token" |
| 23 | +$token = "Bearer " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat")) |
| 24 | +$organization = "my-org" |
| 25 | +$project = "my-project" |
| 26 | +``` |
| 27 | + |
| 28 | +## **Available cmdlets** |
| 29 | + |
| 30 | +| Cmdlet | Description | |
| 31 | +| :-- | :-- | |
| 32 | +| `Get-FSCPSADOTestCase` | Get details of a specific test case by ID | |
| 33 | +| `Get-FSCPSADOTestSuitesByTestPlan` | List all test suites in a test plan | |
| 34 | +| `Get-FSCPSADOTestCasesBySuite` | List all test cases in a test suite | |
| 35 | +| `Get-FSCPSADOTestSuiteByTestCase` | Find which test suite a test case belongs to | |
| 36 | + |
| 37 | +## **Get test case details** |
| 38 | + |
| 39 | +Retrieve detailed information about a specific test case: |
| 40 | + |
| 41 | +``` |
| 42 | +Get-FSCPSADOTestCase ` |
| 43 | + -TestCaseId 1234 ` |
| 44 | + -Project $project ` |
| 45 | + -Organization $organization ` |
| 46 | + -Token $token |
| 47 | +``` |
| 48 | + |
| 49 | +## **List test suites in a test plan** |
| 50 | + |
| 51 | +Get all test suites from a specific test plan: |
| 52 | + |
| 53 | +``` |
| 54 | +$suites = Get-FSCPSADOTestSuitesByTestPlan ` |
| 55 | + -Organization $organization ` |
| 56 | + -Project $project ` |
| 57 | + -TestPlanId 100 ` |
| 58 | + -Token $token |
| 59 | +
|
| 60 | +$suites | ForEach-Object { |
| 61 | + Write-Host "Suite: $($_.name) (ID: $($_.id))" |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +## **List test cases in a test suite** |
| 66 | + |
| 67 | +Get all test cases from a specific test suite within a test plan: |
| 68 | + |
| 69 | +``` |
| 70 | +$testCases = Get-FSCPSADOTestCasesBySuite ` |
| 71 | + -TestSuiteId 1001 ` |
| 72 | + -TestPlanId 100 ` |
| 73 | + -Organization $organization ` |
| 74 | + -Project $project ` |
| 75 | + -Token $token |
| 76 | +
|
| 77 | +$testCases | ForEach-Object { |
| 78 | + Write-Host "Test Case: $($_.testCase.name) (ID: $($_.testCase.id))" |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +## **Find test suite by test case** |
| 83 | + |
| 84 | +Find which test suite a specific test case belongs to: |
| 85 | + |
| 86 | +``` |
| 87 | +Get-FSCPSADOTestSuiteByTestCase ` |
| 88 | + -TestCaseId 1234 ` |
| 89 | + -Project $project ` |
| 90 | + -Organization $organization ` |
| 91 | + -Token $token |
| 92 | +``` |
| 93 | + |
| 94 | +## **Example: Export all test cases from a test plan** |
| 95 | + |
| 96 | +A practical example that lists all test cases across all suites in a test plan: |
| 97 | + |
| 98 | +``` |
| 99 | +$testPlanId = 100 |
| 100 | +
|
| 101 | +# Get all suites in the test plan |
| 102 | +$suites = Get-FSCPSADOTestSuitesByTestPlan ` |
| 103 | + -Organization $organization ` |
| 104 | + -Project $project ` |
| 105 | + -TestPlanId $testPlanId ` |
| 106 | + -Token $token |
| 107 | +
|
| 108 | +foreach ($suite in $suites) { |
| 109 | + Write-Host "=== Suite: $($suite.name) (ID: $($suite.id)) ===" |
| 110 | + |
| 111 | + $testCases = Get-FSCPSADOTestCasesBySuite ` |
| 112 | + -TestSuiteId $suite.id ` |
| 113 | + -TestPlanId $testPlanId ` |
| 114 | + -Organization $organization ` |
| 115 | + -Project $project ` |
| 116 | + -Token $token |
| 117 | + |
| 118 | + foreach ($tc in $testCases) { |
| 119 | + Write-Host " - $($tc.testCase.name) (ID: $($tc.testCase.id))" |
| 120 | + } |
| 121 | +} |
| 122 | +``` |
| 123 | + |
| 124 | +## **Closing comments** |
| 125 | +In this tutorial we showed you how to use the ADO test management cmdlets: |
| 126 | +- **Get-FSCPSADOTestCase** — get details of a test case |
| 127 | +- **Get-FSCPSADOTestSuitesByTestPlan** — list suites in a test plan |
| 128 | +- **Get-FSCPSADOTestCasesBySuite** — list test cases in a suite |
| 129 | +- **Get-FSCPSADOTestSuiteByTestCase** — find which suite a test case belongs to |
| 130 | + |
| 131 | +These cmdlets are useful for test management automation, reporting, and integration with CI/CD pipelines. |
0 commit comments