Skip to content

Commit

Permalink
Merge pull request #47 from jakubch1/main
Browse files Browse the repository at this point in the history
Fix cobertura scenarios
  • Loading branch information
jakubch1 committed Aug 29, 2023
2 parents 9893e40 + b491588 commit 4e5c6d9
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
15 changes: 13 additions & 2 deletions samples/Calculator/scenarios/scenario02/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,29 @@ steps:
- task: DotNetCoreCLI@2
inputs:
command: 'test'
arguments: '--no-build --configuration $(buildConfiguration) --collect "Code Coverage;Format=cobertura"'
arguments: '--no-build --configuration $(buildConfiguration) --collect "Code Coverage;Format=cobertura" --logger trx --results-directory $(Agent.TempDirectory)'
publishTestResults: false
projects: '$(projectPath)' # this is specific to example - in most cases not needed
displayName: 'dotnet test'

- task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '$(Agent.TempDirectory)/**/*.trx'
publishRunAttachments: false

- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: $(Agent.TempDirectory)/**/*.cobertura.xml
```

> **_NOTE:_** To make sure that Code Coverage tab will be visible in Azure DevOps you need to make sure that previous steps will not publish test attachments (`publishRunAttachments: false` and `publishTestResults: false`).
[Full source example](azure-pipelines.yml)

![alt text](azure-pipelines.jpg "Code Coverage tab in Azure DevOps pipelines")
![alt text](azure-pipelines.jpg "Published report generated by report-generator")

![alt text](azure-pipelines2.jpg "Code Coverage tab in Azure DevOps pipelines")

# Report example

Expand Down
9 changes: 8 additions & 1 deletion samples/Calculator/scenarios/scenario02/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ steps:
- task: DotNetCoreCLI@2
inputs:
command: 'test'
arguments: '--no-build --configuration $(buildConfiguration) --collect "Code Coverage;Format=cobertura"'
arguments: '--no-build --configuration $(buildConfiguration) --collect "Code Coverage;Format=cobertura" --logger trx --results-directory $(Agent.TempDirectory)'
publishTestResults: false
projects: '$(projectPath)' # this is specific to example - in most cases not needed
displayName: 'dotnet test'

- task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '$(Agent.TempDirectory)/**/*.trx'
publishRunAttachments: false

- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: $(Agent.TempDirectory)/**/*.cobertura.xml
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions samples/Calculator/scenarios/scenario03/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,29 @@ steps:
- task: DotNetCoreCLI@2
inputs:
command: 'test'
arguments: '--no-build --configuration $(buildConfiguration) --settings samples/Calculator/scenarios/scenario03/coverage.runsettings'
arguments: '--no-build --configuration $(buildConfiguration) --settings samples/Calculator/scenarios/scenario03/coverage.runsettings --logger trx --results-directory $(Agent.TempDirectory)'
publishTestResults: false
projects: '$(projectPath)' # this is specific to example - in most cases not needed
displayName: 'dotnet test'

- task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '$(Agent.TempDirectory)/**/*.trx'
publishRunAttachments: false

- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: $(Agent.TempDirectory)/**/*.cobertura.xml
```

> **_NOTE:_** To make sure that Code Coverage tab will be visible in Azure DevOps you need to make sure that previous steps will not publish test attachments (`publishRunAttachments: false` and `publishTestResults: false`).
[Full source example](azure-pipelines.yml)

![alt text](azure-pipelines.jpg "Code Coverage tab in Azure DevOps pipelines")
![alt text](azure-pipelines.jpg "Published report generated by report-generator")

![alt text](azure-pipelines2.jpg "Code Coverage tab in Azure DevOps pipelines")

# Report example

Expand Down
9 changes: 8 additions & 1 deletion samples/Calculator/scenarios/scenario03/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ steps:
- task: DotNetCoreCLI@2
inputs:
command: 'test'
arguments: '--no-build --configuration $(buildConfiguration) --settings samples/Calculator/scenarios/scenario03/coverage.runsettings'
arguments: '--no-build --configuration $(buildConfiguration) --settings samples/Calculator/scenarios/scenario03/coverage.runsettings --logger trx --results-directory $(Agent.TempDirectory)'
publishTestResults: false
projects: '$(projectPath)' # this is specific to example - in most cases not needed
displayName: 'dotnet test'

- task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '$(Agent.TempDirectory)/**/*.trx'
publishRunAttachments: false

- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: $(Agent.TempDirectory)/**/*.cobertura.xml
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4e5c6d9

Please sign in to comment.