Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
46 views

How to exclude certain projects from being tested in a .NET project using XUnit and Coverlet

So I have a API project, and a Services project in a Visual Studio Solution. I also have separate api.tests.csproj and services.tests.csproj projects. I have a command like dotnet test ... /p:...
stefdude1999's user avatar
0 votes
1 answer
139 views

How to include code coverage for nunit unit test project also in the coverlet and covertura configin azure pipeline with yml

I have 3 projects in my solution including the test project. I get only 2 project in code coverage result in the azure pipeline which excludes the test project. I want to include the test project also ...
b_J's user avatar
  • 125
0 votes
0 answers
9 views

How to show project without reference in tests in SonarQube coverlet .NET test coverage?

I'm trying to add sonarqube test coverage to my project. In .NET solution I got: ProjectA ProjectB ProjectC and test projects TestProjectForA TestProjectForB When I run dotnet test with Include ...
ruddnisrus's user avatar
0 votes
0 answers
46 views

Coverlet doesn't calculate code coverage for tests until another test is added

We have 700 tests in our solution and we use the latest .net and latest coverlet. 3 test files in 1 (out of 30) test solutions are not calculated correctly: But the tests are executed: The ...
PassionateDeveloper's user avatar
2 votes
1 answer
92 views

MStest + Coverlet don't getting up to 100% coverage in cli, but I got 100% in codecov

I recently created a solution from scratch with a C# .NET 8.0 project. The project is only about unit tests and isolated classes, which I intend to be a folder of algorithm exercises. The project has ...
Gonzalo's user avatar
  • 510
2 votes
2 answers
643 views

Files generated during build time appearing on code coverage

I have updated my Azure Functions from in-proc .NET 6 to isolated .NET 8 and I noticed that my code coverage went down sharply. After checking the Cobertura report generated by Coverlet I noticed that ...
paddingtonMike's user avatar
0 votes
1 answer
154 views

Coverlet test coverage: incorrectly use threshold

I have configured coverlet analysis of my .net code in this way: dotnet test \ /p:CollectCoverage=true \ /p:CoverletOutputFormat=cobertura \ /p:Threshold=80 \ /p:Exclude=[*]*.Program%...
dododo's user avatar
  • 4,868
0 votes
1 answer
580 views

Azure DevOps VSTest@2 does not generate code coverage

I'm trying to generate code coverage and publish it using Azure DevOps pipelines. Prerequisites: My .NET version is 4.8 the coverlet.collector package is added to test projects NUnit is used. Here ...
yagudron's user avatar
1 vote
2 answers
888 views

How to exclude GRPC generated C# code from code coverage

We have a C# GRPC service. It references the "Grpc.AspNetCore" NuGet package, which in turn pulls in the "Grpc.Tools" package. From what I can gather, those tools convert our "...
Richardissimo's user avatar
2 votes
1 answer
101 views

Observer Effect with Code Coverage in .NET

I'm trying to implement code coverage for the Sentry .NET SDK. As this is an open source repository, I need to pick a code coverage tool that is freely available so that anyone can build the solution ...
James Crosswell's user avatar
0 votes
1 answer
426 views

Azure DevOps DotNetCoreCLI@2 test fails with coverlet total coverage

My Azure DevOps pipeline is failing on the DotNetCoreCLI@2 step with error code 1, even if the total coverage is above the threshold. When executed locally the command runs without errors and in the ...
Timo's user avatar
  • 108
0 votes
0 answers
554 views

dotnet test cannot find "Plat Code Coverage"

I am trying to run code coverage using coverlet. My test projects are SDK style and have coverlet.collector installed, although some of the referenced projects are not yet in the SDK style. The ...
rbasniak's user avatar
  • 4,954
1 vote
1 answer
1k views

Exclude parameter does not work in dotnet test command with test coverage

I got project structure : -my-application.sln --src ----Api ----ApplicationServices ----Domain ----Infrastructure --tests ----ApplicationServices.UnitTests ----Domain.UnitTests ----Infrastructure....
ruddnisrus's user avatar
1 vote
0 answers
313 views

dotnet cli test --logger with --collect:"XPlat Code Coverage" causes duplicate code coverage files with identical content

When running dotnet test --blame --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./test-results --logger "trx;logfilename=...
Owen Bayley's user avatar
0 votes
0 answers
243 views

How to get TeamCity + XUnit + Coverlet to work?

I am posting this after 2 days of trying various solutions that didn't work for me. This is mostly for my future reference, but I hope others can benefit as well. I used this source as the basis for ...
Bitfiddler's user avatar
  • 4,182
3 votes
1 answer
6k views

How to get .NET code coverage analysis in VS Code?

I wrote NUnit tests to test .NET code. Now I want to see my coverage statistics in VS Code. Is there any way to get visual/textual coverage analysis for .NET unit tests in VS Code? Maybe there is some ...
Yoro's user avatar
  • 1,700
0 votes
1 answer
1k views

Coverlet does not generate cobertura.xml for MSTest test projects

I have a solution with multiple test projects (MSTest). I wanna check my code coverage for the entire solution. To do this, I type the following command: dotnet test --collect:"XPlat Code ...
Aleksej_Shherbak's user avatar
0 votes
1 answer
930 views

Unable to find a datacollector with friendly name 'Format=opencover' - coverlet

I already posted this on GH but as it seems to get no attention there I will try again here. Hi! I cannot for the life of me figure this one out... Below are the commands I am running in my GitLab CI/...
Matheos's user avatar
  • 429
0 votes
1 answer
292 views

coverlet: Unable to instrument module (ArgumentException)

I faced an issue when some projects from solution (NOT ALL) are not being instrumented (have zero coverage, though have active unit tests). All projects in solution have the same package refs and ...
Siarhei Machel's user avatar
2 votes
1 answer
453 views

Coverlet msbuild /p:Exclude not able to exclude third party dlls

/p:Exclude does not seem to work for me - No matter what I try I want to exclude following third party libraries | DocoptNet | 0% | 0% | 0% | +-----------------------------------------+--------+-------...
Tejas Patel's user avatar
  • 1,417
0 votes
0 answers
1k views

When calculate C# solution code coverage, how to include projects not covered by test at all?

I'm using C# to develop a software which contains multiple projects in a Visual Studio solution, and I'm begin adding some unit tests. Solution hierarchy as below, 3 projects for production code, 2 ...
YuWea's user avatar
  • 345
1 vote
0 answers
1k views

dotnet test --collect:"XPlat Code Coverage" taking too long to execute nearly 30-40 minutes in local or Azure pipeline coverlet-coverage

I have a .net6 application with the below dependencies <ItemGroup> <PackageReference Include="Abp.MemoryDb" Version="6.4.0" /> <PackageReference Include=&...
San Jaisy's user avatar
  • 16.9k
0 votes
1 answer
70 views

Coverlet doesn't appear to respect Function Exclusions in my .runsettings file

I have a .runsettings file which excludes autogenerated methods that are typically associated with async/await code, i.e. MoveNext() in my case. This is my .runsettings file: <?xml version="1....
ilitirit's user avatar
  • 16.3k
2 votes
1 answer
4k views

Code Coverage file contains coverage of Irrelevant assemblies does not exclude even exclude with runsettings?

The project I am working on has a test project. As part of the test run, It generates a code coverage file. It used the below command to test and generate coverage XML. dotnet test --collect:"...
Amal Shalika's user avatar
  • 1,237
1 vote
2 answers
469 views

coverlet.collector not adding a .NET MAUI project to the coverage.cobertura.xml

I have a .NET MAUI project and a (Unit) Tests project in the same solution. The Tests project references the .NET MAUI project and the tests run fine. I want to also add code coverage for the .NET ...
dik1977's user avatar
  • 21
0 votes
1 answer
2k views

Cannot exclude assemblies when using coverlet 3.2.0 and a .runsettings file

I am trying to run unit tests using NUnit and coverlet but exclude assemblies that end with the name .Testing from the coverage report. However, whatever I do the file (for example MyProj.Testing.dll) ...
bytedev's user avatar
  • 9,049
0 votes
2 answers
4k views

dotnet test --collect:"XPlat Code Coverage" not consider Api project

I am trying to generate Code coverage report in 2 ways. Using Fine Code Coverage. There i see all 3 projects of me covered & its % of coverage. Using Azure devops Pipeline where i use ...
lokanath das's user avatar
5 votes
3 answers
5k views

coverlet does not create report in azure devops

I am using coverlet.msbuild v3.2.0 coverlet.collector v3.2.0 and dotnet sdk v6.0.402 When I run this test command in powershell (restore and build ran before that) dotnet test --no-build --no-...
mrt181's user avatar
  • 5,286
0 votes
0 answers
194 views

Run dotnet tests without excluding ExcludeFromCoverageAttribute (i.e. consider all code coverable)

I am running test using dotnet test (dotnet SDK version: 6.0.402) the command looks like this "C:/Program Files/dotnet/dotnet.exe" test "D:\MyRepo\MyProj.csproj" /p:...
Sebastian Slutzky's user avatar
6 votes
2 answers
1k views

Exclude AspNetCoreGeneratedDocument Class from coverage report in coverlet

I have this class AspNetCoreGeneratedDocument.Views_Users__AddOrUpdateUser appearring in the code coverage result for each view in the Views folder, Exemple: AspNetCoreGeneratedDocument....
KA-Yasso's user avatar
  • 401
-1 votes
1 answer
1k views

Can't produce coverage in Docker container

I'm having trouble getting coverlet to run in my docker container. My problems seems similar to this issue, although the problem persists, and there are some differences. Setup .NET 6 tests project. ...
RPM1984's user avatar
  • 73k
1 vote
1 answer
782 views

Dotnet test coverage always null

I have an issue with test coverage. When I run this command dotnet test ../XZrcndee.sln --output ../coverage /p:CollectCoverage=true /p:CoverletOutput=results\coverage /p:CoverletOutput=..\results\...
Udemytur's user avatar
  • 321
0 votes
1 answer
152 views

Sonarqube: Test coverage comes as 0

I am using sonar integration for the c# x unit test project. But always test coverage is coming as 0. How can I resolve this
Chathu.Thanthrige's user avatar
0 votes
1 answer
1k views

Code coverage gets generated only for Tests project

I've got a project (say A.csproj) and a tests project (say T.csproj). T has coverlet.msbuild and Microsoft.NET.Test.Sdk as nuget references. T has a .runsettings file with no include include/exclude ...
hexcode's user avatar
  • 403
0 votes
1 answer
719 views

C# - Exclude lambda expression from code coverage

I have a particular third party class that has an event handler. I have setup MyEventHandler method which I am able to test using reflection, so I know that is well tested. However I am getting a ...
touchofevil's user avatar
2 votes
0 answers
2k views

Coverlet is unable to instrument any modules for my test project

When running this command (using coverlet underneath): dotnet test /p:CollectCoverage=true .\My.Test.Solution.sln (also tried other variations including coverlet itself) I'm getting a lot of warnings ...
kbd's user avatar
  • 4,429
0 votes
1 answer
2k views

Coverlet generated coverage.cobertura.xml empty source full path in filename

It works fine in most of my projects, but I have one where the coverage.cobertura.xml is generating like: <?xml version="1.0" encoding="utf-8"?> <coverage line-rate="...
Lee Tickett's user avatar
  • 5,997
1 vote
1 answer
1k views

Get branches coverage on Visual Studio

Using the CodeCoverage of Visual Studio I'm not able to see the branches coverage results. What would be the best way to get it ?
PierreP's user avatar
  • 147
0 votes
1 answer
147 views

Running a Target only once per solution

I'm trying to find a way to run a specific target only once per solution after tests are done. I have a solution with multiple test projects. Each has integration with coverlet.msbuild, hence they ...
Eugene Krapivin's user avatar
0 votes
1 answer
878 views

Exclude Blazor pages from code coverage via .runsettings

I have this little Blazor application. Now I'd like to exclude all Blazor pages from code coverage via .runsettings. The pages are located under /RaspiFanController/Pages/. My tests are using NUnit ...
mu88's user avatar
  • 5,334
4 votes
1 answer
1k views

Error when running unit test from console using Visual Studio 17.1

Getting the error below when running the unit test from the command line. This runs fine on Windows 10 machine and is failing in Windows 7. dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=...
TrustyCoder's user avatar
  • 4,789
3 votes
1 answer
2k views

Unable to add coverlet nuget package(s) - Version string portion was too short or too long

When I try to add coverlet.msbuild to my test project I get this error: The expression "[System.Version]::Parse('')" cannot be evaluated. Version string portion was too short or too long. C:...
kbd's user avatar
  • 4,429
7 votes
1 answer
9k views

exclude code coverage for ef core migration files

I want to exclude all auto generated migration files from code coverage caculation. I can't change the dotnet test command in the build pipeline so I guess my only friend is the [...
lastr2d2's user avatar
  • 3,948
0 votes
1 answer
432 views

TeamCity + ReportGenerator

Good morning guys I am using coverlet to run my tests in TeamCity. This works fine after I run the tests I would like to generate the report. Write-Host "Installing report generator" -...
miechooy's user avatar
  • 3,422
1 vote
0 answers
775 views

C# code coverage for files in test project

I have a project A for which I wrote unit tests in test project UnitTests. I use MSTest. I wrote some testing utils in the file UnitTestUtils.cs which simplify testing project A. I also covered these ...
elo's user avatar
  • 529
1 vote
0 answers
207 views

Code Coverage int .NET 5 Web API with Coverlet

I've web Api build it .NET 5.0. Web API structure: Main Web Project (Contains controllers and other client specific data) Infrastructure Project (It has services and repositories with more business ...
Bharat's user avatar
  • 6,085
1 vote
1 answer
2k views

Latest/previous ver return error "The expression "[System.Version]::Parse('')" cannot be evaluated. Version string portion was too short or too long."

Try to install latest ver (3.1.0) of coverlet.msuild using nuget package manager for C# Unit Test Project on VS 2019 Community. I am return the error: "The expression "[System.Version]::...
rpietkiewicz's user avatar
0 votes
1 answer
1k views

Run MsBuild.Coverlet without dotnet command

I have an old project (VS2105) I'm unable to use the dotnet command so I'm trying to use coverlet.msbuild task. MSBuild.exe my-solution.sln /t:My_Project_Test:InstrumentModules /t:My_Project_Test:...
Symon Suna's user avatar
0 votes
0 answers
213 views

Provide code coverage for blazor inline code

I've got code like this in a blazor component... <MyComponent OnSomeEvent="@((id) => SomeMethod(id)" /> Now coverlet says that this line isn't tested. In the containing control I'm ...
Stuart Hemming's user avatar
0 votes
1 answer
517 views

Code coverage of legacy applications in end to end tests

I am building a test suite, specflow and XUnit based, that has all kinds of end to end tests that run a few legacy .net 4.5 applications The legacy applications hardly have any unit tests. I would ...
jeroentjeathome's user avatar