.NET Core 2.1
MSTest.TestAdapter v1.4.0
MSTest.TestFramework v.1.4.0
Microsoft.NET.Test.Sdk v 15.9.0
Create a .NET Core Test project with a test
Add a dependency to the FluentAssertions NuGet pkg
dotnet test --blame --collect:"Code Coverage"
Open the coverage file
I would not see coverage details for FluentAssertions
I see coverage details for FluentAssertions
I discovered the .runsettings file. At the solution level, I created a codecoverage.runsettings file. I then run this command:
dotnet test --blame --collect:"Code Coverage" --settings:..\codecoverage.runsettings
This appears to give me what I need. Here are my runsettings. Hopefully I'm not leaving out anything important.
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Culture=neutral">
<Configuration>
<CodeCoverage>
<!-- Match assembly file paths: -->
<ModulePaths>
<Include>
<ModulePath>.*\mydomains.*.dll</ModulePath>
</Include>
<Exclude>
<ModulePath>.*tests.dll</ModulePath>
</Exclude>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
@GoFightNguyen Currently we do instrument all dependent dlls (whether they come from 3rd part dependency or nuget reference).
In this case we try to collect code coverage for FluentAssertions.
However this package can be excluded from coverage report by modifying the runsettings as you have mentioned.
This is working as designed :)
Most helpful comment
I discovered the .runsettings file. At the solution level, I created a codecoverage.runsettings file. I then run this command:
dotnet test --blame --collect:"Code Coverage" --settings:..\codecoverage.runsettingsThis appears to give me what I need. Here are my runsettings. Hopefully I'm not leaving out anything important.
<?xml version="1.0" encoding="utf-8"?> <RunSettings> <DataCollectionRunSettings> <DataCollectors> <DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Culture=neutral"> <Configuration> <CodeCoverage> <!-- Match assembly file paths: --> <ModulePaths> <Include> <ModulePath>.*\mydomains.*.dll</ModulePath> </Include> <Exclude> <ModulePath>.*tests.dll</ModulePath> </Exclude> </ModulePaths> </CodeCoverage> </Configuration> </DataCollector> </DataCollectors> </DataCollectionRunSettings> </RunSettings>