Skip to content

Commit

Permalink
[WIP] Coverage test
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienBraillard committed Jul 7, 2024
1 parent 3270177 commit 998fd09
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,12 @@ jobs:
run: |
echo "# ❔ <b>Test results</b>" >> $GITHUB_STEP_SUMMARY
dotnet test --no-build
continue-on-error: true
continue-on-error: true

- name: 📝 Code Coverage report
run: |
dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.1.23
reportgenerator -reports:${{github.workspace}}/tests/results/coverage.*.xml -targetdir:${{github.workspace}}/report -reporttypes:MarkdownSummaryGithub "-filefilters:-*.g.cs" -verbosity:Warning
sed -i 's/# Summary/## 📝 Code Coverage/g' ${{github.workspace}}/report/SummaryGithub.md
sed -i 's/## Coverage/### Code Coverage details/g' ${{github.workspace}}/report/SummaryGithub.md
cat ${{github.workspace}}/report/*.md >> $GITHUB_STEP_SUMMARY
12 changes: 12 additions & 0 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,16 @@
</VSTestLogger>
</PropertyGroup>

<PropertyGroup Label="Test output: All">
<!-- Collect code coverage -->
<CollectCoverage>true</CollectCoverage>
<!-- Save code coverage analysis using opencover format in same folder than the unit test rsults -->
<CoverletOutputFormat>json,lcov,opencover</CoverletOutputFormat>
<CoverletOutput>$([MSBuild]::EnsureTrailingSlash($(VSTestResultsDirectory)))</CoverletOutput>
<!-- Ensure that sequential runs are merged together -->
<MergeWith>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory), 'results', 'coverage.$(TargetFramework).json'))</MergeWith>
<!-- Exclude code marked with specific attributes -->
<ExcludeByAttribute>ObsoleteAttribute,GeneratedCodeAttribute,CompilerGeneratedAttribute,ExcludeFromCodeCoverage</ExcludeByAttribute>
</PropertyGroup>

</Project>

0 comments on commit 998fd09

Please sign in to comment.