How to exclude test assemblies
See original GitHub issueShouldn’t test assemblies be excluded by default according to #618 or did something change?
In any case, I tried to exclude test assemblies by setting the IncludeTestAssembly
flag to false but some test assemblies still appear in the code coverage report. What may be the issue?
Here is the .runsettings file:
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>cobertura,opencover</Format>
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute,TestSDKAutoGeneratedCode</ExcludeByAttribute>
<IncludeTestAssembly>false</IncludeTestAssembly>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
The command I’m using is dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
How to exclude test assemblies from VS code coverage?
The answer is here - https://learn.microsoft.com/en-us/visualstudio/test/customizing-code-coverage-analysis?view=vs-2019 and here ...
Read more >Customizing Code Coverage Analysis - Visual Studio
To exclude test code from the code coverage results and only include application code, add the ExcludeFromCodeCoverageAttribute attribute to ...
Read more >Need to exclude a Particular Test Method from Build ...
If you are running the pipeline with the “Test assemblies” option, please try the Test filter critera input. It could filter the tests...
Read more >Excluding Your .NET Test Project From Code Coverage
Include the code below in a Directory.Build.props file at the root of your tests folder, where all your projects are located. The configuration ......
Read more >Including and Excluding Assemblies from Code Coverage
What I want to do is exclude the test assemblies from the coverage numbers, but the ExcludeFromCodeCoverageAttribute can't be applied to ...
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
Closing for stale conversation, feel free to reopen if needed.
@MarcoRossignoli Apologies for the delay here. I tried to make a repro sample, and didn’t get the same behaviour.
Our production code is a mix of .NET Framework and .NET Core, and I think one test assembly was being run as a .NET Framework test with vstest.console but it was a .NET Core test so that might have confused things. Also, it’s possible that the Azure DevOps plugins pass different defaults than the tools do locally, so I’m working on an MSBuild proj for the pipeline to call.
I’ll let you know if I run into more issues as I progress