Zero Coverage Reported coverlet.msbuild
See original GitHub issueSo I run
dotnet test /p:CollectCoverage=true /p:CoverletOutput=./coverage_report/raw_coverage_results.xml /p:CoverletOutputFormat=cobertura
I see that my tests ran successfully
Test run for C:\blahblah\Test\bin\Debug\netcoreapp3.0\Test.dll(.NETCoreApp,Version=v3.0)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Test Run Successful.
Total tests: 28
Passed: 28
Total time: 1.4392 Minutes
Calculating coverage result...
Generating report '.\coverage_report\raw_coverage_results.xml'
+--------+------+--------+--------+
| Module | Line | Branch | Method |
+--------+------+--------+--------+
+---------+------+--------+--------+
| | Line | Branch | Method |
+---------+------+--------+--------+
| Total | 100% | 100% | 100% |
+---------+------+--------+--------+
| Average | NaN% | NaN% | NaN% |
+---------+------+--------+--------+
But my resulting file (.\coverage_report\raw_coverage_results.xml) ends up having no information. Just the following:
<?xml version="1.0" encoding="utf-8"?>
<coverage line-rate="1" branch-rate="1" version="1.9" timestamp="1580346044" lines-covered="0" lines-valid="0" branches-covered="0" branches-valid="0">
<sources />
<packages />
</coverage>
Here’s my result of dotnet list package
Project 'Test' has the following package references
[netcoreapp3.0]:
Top-level Package Requested Resolved
> coverlet.msbuild 2.8.0 2.8.0
> Microsoft.NET.Test.Sdk 16.4.0 16.4.0
> nunit 3.12.0 3.12.0
> NUnit3TestAdapter 3.13.0 3.13.0
> System.Configuration.ConfigurationManager 4.5.0 4.5.0
> System.Json 4.5.0 4.5.0
I have a feeling this may have to do with me upgrading to .net core 3.0. I was previously running my main application under the .net framework version 4.7.2 and I was getting coverage results back then.
Any help would be greatly appreciated.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
coverlet/Documentation/MSBuildIntegration.md at master
The Coverlet MSBuild task sets the CoverletReport MSBuild item so that you can easily use the produced coverage reports. For example, using ReportGenerator ......
Read more >unit testing - C# Coverlet results always empty
I am using dotnet 8, from dotnet test DemoTest\DemoTest.csproj --no-build --collect:"XPlat Code Coverage" --logger "trx;LogFileName=tests.xml" / ...
Read more >Use code coverage for unit testing - .NET
This article discusses the usage of code coverage for unit testing with Coverlet and report generation using ReportGenerator.
Read more >How to setup your dotnet project with test coverage reporting
I want to talk about Coverlet and ReportGenerator, and maybe show you some interesting MSBuild tricks along the way.
Read more >How to view code coverage with Coverlet and Visual ...
The first thing to do to add code coverage reports to our project is to install Coverlet, a NuGet package, whose documentation can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, thanks again for the help. You’re doing an outstanding job supporting this tool.
I reviewed the code and yes, my common.cs file uses Fody/PropertyChanged, which injects code into some of the classes in that file to deal with OnPropertyChanged events, making it autogenerated.
It makes perfect sense. Trying to measure coverage on code which gets modified dynamically prior to compilation is a quixotic task. Thank you so much for helping me come to this conclusion.
Glad to hear! thanks for using coverlet!