@@ -107,7 +107,7 @@ function DotNetTest {
107107
108108 $additionalArgs = @ ()
109109
110- # Generate TRX test results for codecov
110+ # Generate test results for codecov
111111 $testResultsDir = Join-Path $solutionPath " test-results"
112112 if (! (Test-Path $testResultsDir )) {
113113 New-Item - ItemType Directory - Path $testResultsDir - Force | Out-Null
@@ -121,6 +121,10 @@ function DotNetTest {
121121 $additionalArgs += " --results-directory"
122122 $additionalArgs += $projectResultsDir
123123
124+ # Enable TUnit's built-in JUnit reporter for Codecov Test Analytics
125+ $env: TUNIT_ENABLE_JUNIT_REPORTER = " true"
126+ $env: JUNIT_XML_OUTPUT_PATH = (Join-Path $projectResultsDir " ${projectName} -junit.xml" )
127+
124128 $additionalArgs += " --coverage"
125129 $additionalArgs += " --coverage-output-format"
126130 $additionalArgs += " cobertura"
@@ -129,10 +133,15 @@ function DotNetTest {
129133 $additionalArgs += " --coverage-settings"
130134 $additionalArgs += (Join-Path $solutionPath " codecoverage.runsettings" )
131135
132- & $dotnet test -- project $Project -- configuration " Release" -- no- build $additionalArgs
136+ try {
137+ & $dotnet test -- project $Project -- configuration " Release" -- no- build $additionalArgs
133138
134- if ($LASTEXITCODE -ne 0 ) {
135- throw " dotnet test failed with exit code $LASTEXITCODE "
139+ if ($LASTEXITCODE -ne 0 ) {
140+ throw " dotnet test failed with exit code $LASTEXITCODE "
141+ }
142+ }
143+ finally {
144+ $env: JUNIT_XML_OUTPUT_PATH = $null
136145 }
137146}
138147
0 commit comments