I’ve implemented exactly this solution for multiple teams using ado-2024. The key is addressing all four aspects of your gate configuration systematically.
Test Gate Configuration:
Replace your single gate with a multi-tier approach using test categories:
gates:
- task: TestResultsGate@1
displayName: 'Critical Tests Gate'
inputs:
testRunTitle: 'Regression Suite'
testCaseFilter: 'Priority=0|Priority=1'
minimumPassRate: 100
- task: TestResultsGate@1
displayName: 'Standard Tests Gate'
inputs:
testRunTitle: 'Regression Suite'
testCaseFilter: 'Priority=2'
minimumPassRate: 95
Pass Rate Thresholds:
Create a variable group named ‘TestGateThresholds’ with these values:
- `P0_PassRate: 100
- `P1_PassRate: 100
- `P2_PassRate: 95
- `P3_PassRate: 90
Reference them in your gates:
minimumPassRate: $(P0_PassRate)
Test Impact Analysis:
Enable impact analysis by adding this to your test execution task:
- task: VSTest@2
inputs:
testSelector: 'testRun'
testImpactEnabled: true
runOnlyImpactedTests: false
collectTestImpact: true
Then filter your gate to only evaluate impacted tests:
testCaseFilter: 'Priority<=1&ImpactedByChanges=true'
Variable Groups:
Set up environment-specific thresholds. For production:
TestGateThresholds-Prod:
CriticalPassRate: 100
StandardPassRate: 98
UIPassRate: 95
For staging, use more lenient thresholds to catch issues early without blocking:
TestGateThresholds-Staging:
CriticalPassRate: 95
StandardPassRate: 90
UIPassRate: 85
Flaky Test Handling:
Add a pre-gate script to exclude flaky tests:
- task: PowerShell@2
inputs:
script: |
$flakyTests = Invoke-RestMethod -Uri "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/test/runs/$(TestRunId)/results?api-version=7.1&outcomes=Failed&$top=100"
$flakyTests.value | Where-Object {$_.failureType -eq 'KnownIssue'} | ForEach-Object {
Write-Host "##vso[task.setvariable variable=ExcludeTests]$($_.testCase.name)"
}
This approach reduced our production deployment delays from 12+ hours to under 1 hour, while maintaining quality standards. The key is categorizing tests properly in Test Plans before implementing the gates.