Skip to content

Commit 1f7c3eb

Browse files
authored
Publish test results to ADO pipeline (#1229)
1 parent 9ab8fa4 commit 1f7c3eb

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Build/build-functions.psm1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
$root = "$PSScriptRoot\.."
22
$artifactsDir = "$root\Artifacts"
33
$nugetOutDir = "$root\Artifacts\NuGet"
4-
$testReportDir = "$root\Artifacts\Logs"
4+
$logsDir = "$root\Artifacts\Logs"
5+
$testReportDir = "$root\Artifacts\TestResults"
56
$testCoverageDir = "$root\Artifacts\Coverage"
67
$nuget = "$root\Tools\NuGet.exe"
78
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
@@ -31,7 +32,7 @@ function Update-GeneratedCode {
3132
function Start-Build([boolean] $IncludeNanoFramework = $false) {
3233
write-host -foreground blue "Start-Build...`n---"
3334

34-
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.msbuild.log"
35+
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$logsDir\UnitsNet.msbuild.log"
3536

3637
$appVeyorLoggerDll = "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
3738
$appVeyorLoggerNetCoreDll = "C:\Program Files\AppVeyor\BuildAgent\dotnetcore\Appveyor.MSBuildLogger.dll"
@@ -47,7 +48,7 @@ function Start-Build([boolean] $IncludeNanoFramework = $false) {
4748
else
4849
{
4950
write-host -foreground green "Build .NET nanoFramework."
50-
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.NanoFramework.msbuild.log"
51+
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$logsDir\UnitsNet.NanoFramework.msbuild.log"
5152
$appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerDll") { "/logger:$appVeyorLoggerDll" } else { "" }
5253

5354
# msbuild does not auto-restore nugets for this project type
@@ -74,7 +75,6 @@ function Start-Tests {
7475
write-host -foreground blue "Run tests...`n---"
7576
foreach ($projectPath in $projectPaths) {
7677
$projectFileNameNoEx = [System.IO.Path]::GetFileNameWithoutExtension($projectPath)
77-
$reportFile = "$testReportDir\${projectFileNameNoEx}.xunit.xml"
7878
$coverageReportFile = "$testCoverageDir\${projectFileNameNoEx}.coverage.xml"
7979
$projectDir = [System.IO.Path]::GetDirectoryName($projectPath)
8080

@@ -84,6 +84,8 @@ function Start-Tests {
8484
# Create coverage report for this test project
8585
& dotnet dotcover test `
8686
--no-build `
87+
--logger trx `
88+
--results-directory "$testReportDir" `
8789
--dotCoverFilters="+:module=UnitsNet*;-:module=*Tests" `
8890
--dotCoverOutput="$coverageReportFile" `
8991
--dcReportType=DetailedXML

azure-pipelines-pr.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ stages:
4646
pwsh: true
4747
workingDirectory: '$(Build.SourcesDirectory)'
4848

49+
- task: PublishTestResults@2
50+
condition: always()
51+
inputs:
52+
testResultsFormat: "VSTest"
53+
testResultsFiles: "*.trx"
54+
searchFolder: $(Build.SourcesDirectory)\Artifacts\TestResults
55+
mergeTestResults: true
56+
4957
- task: PowerShell@2
5058
displayName: Upload to codecov.io
5159
env:

0 commit comments

Comments
 (0)