Skip to content

Commit 530e63b

Browse files
Copilotbaywet
andauthored
ci(azure): simplify mtp test execution
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
1 parent dfcc2dc commit 530e63b

1 file changed

Lines changed: 7 additions & 37 deletions

File tree

.azure-pipelines/ci-build.yml

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -101,43 +101,13 @@ extends:
101101

102102
# Run the Unit test
103103
- pwsh: |
104-
$testResultsDirectory = "$(Agent.TempDirectory)\TestResults"
105-
New-Item -ItemType Directory -Force -Path $testResultsDirectory | Out-Null
106-
107-
$testExecutableCandidates = @(Get-ChildItem -Path "$(Build.SourcesDirectory)\test" -Recurse -Filter "*.Tests.exe")
108-
Write-Host "Discovered $($testExecutableCandidates.Count) test executable candidate(s):"
109-
$testExecutableCandidates | ForEach-Object { Write-Host " $($_.FullName)" }
110-
111-
$testExecutables = @($testExecutableCandidates | Where-Object {
112-
# Match the app produced by its own project output: test\<ProjectName>\bin\<Configuration>\<TFM>\<ProjectName>.exe.
113-
$_.Directory.Parent.Name -eq "$(BuildConfiguration)" -and
114-
$_.Directory.Parent.Parent.Name -eq "bin" -and
115-
$_.BaseName -eq $_.Directory.Parent.Parent.Parent.Name -and
116-
# xUnit v3 MTP test apps copy the runner assembly next to the generated executable.
117-
@(Get-ChildItem -Path $_.DirectoryName -Filter "xunit.v3.mtp*.dll").Count -gt 0
118-
})
119-
if ($testExecutables.Count -eq 0) {
120-
Write-Error "No xUnit MTP test executable found"
121-
exit 1
122-
}
123-
124-
$exitCode = 0
125-
foreach ($testExecutable in $testExecutables | Sort-Object FullName) {
126-
$targetFramework = Split-Path -Path $testExecutable.DirectoryName -Leaf
127-
& $testExecutable.FullName `
128-
--report-xunit-trx `
129-
--report-xunit-trx-filename "$($testExecutable.BaseName)-$targetFramework.trx" `
130-
--results-directory $testResultsDirectory `
131-
--minimum-expected-tests 1
132-
if ($LASTEXITCODE -ne 0) {
133-
Write-Error "$($testExecutable.Name) failed with exit code $LASTEXITCODE"
134-
if ($exitCode -eq 0) {
135-
$exitCode = $LASTEXITCODE
136-
}
137-
}
138-
}
139-
140-
exit $exitCode
104+
dotnet test "$(Build.SourcesDirectory)\Microsoft.OpenApi.slnx" `
105+
--configuration $(BuildConfiguration) `
106+
--no-build `
107+
-- `
108+
--report-xunit-trx `
109+
--results-directory "$(Agent.TempDirectory)\TestResults" `
110+
--minimum-expected-tests 1
141111
displayName: 'test'
142112
143113
- task: PublishTestResults@2

0 commit comments

Comments
 (0)