Skip to content

Commit 3491287

Browse files
TestFramework: Fix coverage (#8581)
1 parent e1aadba commit 3491287

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

azure-pipelines.yml

+27-27
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ variables:
3535
- name: UnitTestProjectPath
3636
value: 'analyzers\tests\SonarAnalyzer.Test\'
3737
- name: UnitTestResultsPath
38-
value: '$(Agent.TempDirectory)\TestResults'
38+
value: '$(Build.SourcesDirectory)\TestResults'
3939
- name: CoveragePath
40-
value: '$(Agent.TempDirectory)\coverage'
40+
value: '$(Build.SourcesDirectory)\coverage'
4141
- name: UnitTestExclusionsPattern
4242
value: 'analyzers/tests/SonarAnalyzer.Test/TestCases/**/*'
4343
- name: isReleaseBranch
@@ -222,25 +222,25 @@ stages:
222222
strategy:
223223
matrix:
224224
Net48:
225-
FrameworkMoniker: 'net48'
226-
CoverageArtifactName: 'DotnetCoverageNet48'
227-
TestResultsArtifactName: 'DotnetTestResultsNet48'
225+
CoverageArtifactName: 'DotNetCoverageNet48'
226+
TestResultsArtifactName: 'DotNetTestResultsNet48'
228227
ProjectFilePath: 'tests\SonarAnalyzer.Test\SonarAnalyzer.Test.csproj'
228+
FrameworkMoniker: 'net48'
229229
Net70:
230-
FrameworkMoniker: 'net7.0-windows'
231-
CoverageArtifactName: 'DotnetCoverageNet7'
232-
TestResultsArtifactName: 'DotnetTestResultsNet7'
230+
CoverageArtifactName: 'DotNetCoverageNet7'
231+
TestResultsArtifactName: 'DotNetTestResultsNet7'
233232
ProjectFilePath: 'tests\SonarAnalyzer.Test\SonarAnalyzer.Test.csproj'
233+
FrameworkMoniker: 'net7.0-windows'
234234
Net80:
235-
FrameworkMoniker: 'net8.0-windows'
236-
CoverageArtifactName: 'DotnetCoverageNet8'
237-
TestResultsArtifactName: 'DotnetTestResultsNet8'
235+
CoverageArtifactName: 'DotNetCoverageNet8'
236+
TestResultsArtifactName: 'DotNetTestResultsNet8'
238237
ProjectFilePath: 'tests\SonarAnalyzer.Net8.Test\SonarAnalyzer.Net8.Test.csproj'
238+
FrameworkMoniker: 'net8.0-windows'
239239
TestFramework:
240-
FrameworkMoniker: 'net7.0-windows'
241-
CoverageArtifactName: 'DotnetCoverageTestFramework'
242-
TestResultsArtifactName: 'DotnetTestResultsTestFramework'
240+
CoverageArtifactName: 'DotNetCoverageTestFramework'
241+
TestResultsArtifactName: 'DotNetTestResultsTestFramework'
243242
ProjectFilePath: 'tests\SonarAnalyzer.TestFramework.Test\SonarAnalyzer.TestFramework.Test.csproj'
243+
FrameworkMoniker: 'net7.0-windows'
244244

245245
steps:
246246
- task: DownloadPipelineArtifact@2
@@ -251,7 +251,7 @@ stages:
251251

252252
- powershell: |
253253
cd analyzers
254-
& dotnet test $(ProjectFilePath) -f $(FrameworkMoniker) -c $(BuildConfiguration) -l trx --results-directory $(UnitTestResultsPath) /p:AltCover=true,AltCoverForce=true,AltCoverVisibleBranches=true,AltCoverAssemblyFilter='Moq|Humanizer|AltCover|Microsoft.VisualStudio.TestPlatform.*|.*Test',AltCoverPathFilter='SonarAnalyzer\.CFG\\ShimLayer|SonarAnalyzer\.ShimLayer\.CodeGeneration',AltCoverAttributeFilter='ExcludeFromCodeCoverage',AltCoverReport=$(CoveragePath)/coverage.$(FrameworkMoniker).xml
254+
& dotnet test $(ProjectFilePath) -f $(FrameworkMoniker) -c $(BuildConfiguration) -l trx --results-directory $(UnitTestResultsPath) /p:AltCover=true,AltCoverForce=true,AltCoverVisibleBranches=true,AltCoverAssemblyFilter="Moq|Humanizer|AltCover|Microsoft.VisualStudio.TestPlatform.*|\.Test^",AltCoverPathFilter="SonarAnalyzer\.CFG\\ShimLayer|SonarAnalyzer\.ShimLayer\.CodeGeneration",AltCoverAttributeFilter="ExcludeFromCodeCoverage",AltCoverReport="$(CoveragePath)/coverage.$(CoverageArtifactName).xml"
255255
displayName: '.Net UTs'
256256
257257
- task: PublishPipelineArtifact@1
@@ -302,8 +302,8 @@ stages:
302302
projectVersion: '$(SONAR_PROJECT_VERSION)'
303303
extraProperties: |
304304
sonar.verbose=true
305-
sonar.cs.opencover.reportsPaths="$(Build.SourcesDirectory)/coverage/**.xml"
306-
sonar.cs.vstest.reportsPaths="$(Build.SourcesDirectory)/TestResults/*.trx"
305+
sonar.cs.opencover.reportsPaths="$(CoveragePath)/*.xml"
306+
sonar.cs.vstest.reportsPaths="$(UnitTestResultsPath)/*.trx"
307307
sonar.test.exclusions="$(UnitTestExclusionsPattern)"
308308
sonar.analysis.buildNumber=$(Build.BuildId)
309309
sonar.analysis.pipeline=$(Build.BuildId)
@@ -323,8 +323,8 @@ stages:
323323
projectVersion: '$(SONAR_PROJECT_VERSION)'
324324
extraProperties: |
325325
sonar.verbose=true
326-
sonar.cs.opencover.reportsPaths="$(Build.SourcesDirectory)/coverage/**.xml"
327-
sonar.cs.vstest.reportsPaths="$(Build.SourcesDirectory)/TestResults/*.trx"
326+
sonar.cs.opencover.reportsPaths="$(CoveragePath)/*.xml"
327+
sonar.cs.vstest.reportsPaths="$(UnitTestResultsPath)/*.trx"
328328
sonar.test.exclusions="$(UnitTestExclusionsPattern)"
329329
sonar.analysis.buildNumber=$(Build.BuildId)
330330
sonar.analysis.pipeline=$(Build.BuildId)
@@ -356,49 +356,49 @@ stages:
356356
- task: DownloadPipelineArtifact@2
357357
displayName: 'Download coverage reports'
358358
inputs:
359-
artifact: DotnetCoverageNet48
359+
artifact: DotNetCoverageNet48
360360
targetPath: 'coverage'
361361

362362
- task: DownloadPipelineArtifact@2
363363
displayName: 'Download coverage reports'
364364
inputs:
365-
artifact: DotnetCoverageNet7
365+
artifact: DotNetCoverageNet7
366366
targetPath: 'coverage'
367367

368368
- task: DownloadPipelineArtifact@2
369369
displayName: 'Download coverage reports'
370370
inputs:
371-
artifact: DotnetCoverageNet8
371+
artifact: DotNetCoverageNet8
372372
targetPath: 'coverage'
373373

374374
- task: DownloadPipelineArtifact@2
375375
displayName: 'Download coverage reports'
376376
inputs:
377-
artifact: DotnetCoverageTestFramework
377+
artifact: DotNetCoverageTestFramework
378378
targetPath: 'coverage'
379379

380380
- task: DownloadPipelineArtifact@2
381381
displayName: 'Download test results'
382382
inputs:
383-
artifact: DotnetTestResultsNet48
383+
artifact: DotNetTestResultsNet48
384384
targetPath: 'TestResults'
385385

386386
- task: DownloadPipelineArtifact@2
387387
displayName: 'Download test results'
388388
inputs:
389-
artifact: DotnetTestResultsNet7
389+
artifact: DotNetTestResultsNet7
390390
targetPath: 'TestResults'
391391

392392
- task: DownloadPipelineArtifact@2
393393
displayName: 'Download test results'
394394
inputs:
395-
artifact: DotnetTestResultsNet8
395+
artifact: DotNetTestResultsNet8
396396
targetPath: 'TestResults'
397397

398398
- task: DownloadPipelineArtifact@2
399399
displayName: 'Download test results'
400400
inputs:
401-
artifact: DotnetTestResultsTestFramework
401+
artifact: DotNetTestResultsTestFramework
402402
targetPath: 'TestResults'
403403

404404
- powershell: |

0 commit comments

Comments
 (0)