coverlet.msbuild 6.0.4 does not generate coverage report when any test fails #1932
Problem DescriptionWhen running tests with coverlet.msbuild 6.0.4, the coverage report (coverage.cobertura.xml) is not generated if at least one test fails. This occurs even when tests have run partially and coverage data should theoretically be available. We need this to work in our GitLab CI pipeline — we want to display code coverage even for failed test runs. Environment:
Steps to Reproduce
Actual Behavior
Expected BehaviorThe coverage report should be generated regardless of test pass/fail status. In CI pipelines (especially GitLab), we need to see coverage metrics even when some tests are failing — e.g., to track regressions or understand which parts of the code were executed. Additional ContextWe are aware of /p:Threshold which fails the build on low coverage — that is not our issue. We do not want to fail the build due to low coverage; we just want the coverage file to be saved even when tests fail. It seems Coverlet currently assumes: "If any test fails, the coverage data is invalid and should not be saved" — but for CI visibility, this is too strict. |
Replies: 2 comments
|
Thank you for starting this discussion. Please use the latest coverlet.msbuild 10.0.1 package.
Regarding this statement:
This is not an intentional Coverlet behavior. Coverlet does not treat failed tests as invalidating the collected coverage data. If coverage output is not being generated when tests fail, the reason may be that dotnet test terminates with an error or aborts execution before Coverlet can complete its processing and write the report. You could use coverlet.collector as alternative package which also allows to create diagnostic logs and uses out-of-process model. |
|
This discussion is obsolete. |

Thank you for starting this discussion.
Please use the latest coverlet.msbuild 10.0.1 package.
Regarding this statement:
This is not an intentional Coverlet behavior. Coverlet does not treat failed tests as invalidating the collected coverage data.
If coverage output is not being generated when tests fail, the reason may be that dotnet test terminates with an error or aborts execution before Coverlet can complete its processing and write the report.
You could use coverlet.collector as alternative package which also allows to create …