-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zero coverage in .net core 3 when using MassTransit #573
Comments
Could be a dup of #506 but thak's for repro...now I can test on my local. |
@ittennull I found the issue.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CoverletDemo\CoverletDemo.csproj" />
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>cobertura</Format>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<InProcDataCollectionRunSettings>
<InProcDataCollectors>
<InProcDataCollector assemblyQualifiedName="Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null"
friendlyName="XPlat Code Coverage"
enabled="True"
codebase="coverlet.collector.dll" />
</InProcDataCollectors>
</InProcDataCollectionRunSettings>
</RunSettings> And use integrated collector https://github.com/tonerdo/coverlet#vstest-integration
On my local will be generated a valid cobertura file with hit on lines <?xml version="1.0" encoding="utf-8"?>
<coverage line-rate="0.2" branch-rate="0.2" version="1.9" timestamp="1569853633" lines-covered="5" lines-valid="25" branches-covered="2" branches-valid="10">
<sources>
<source></source>
</sources>
<packages>
<package name="CoverletDemo" line-rate="0.2" branch-rate="0.2" complexity="11">
<classes>
<class name="CoverletDemo.Service" filename="C:\git\coverletissue\coverletdemo-master\CoverletDemo\Service.cs" line-rate="0.2083" branch-rate="0.5" complexity="4">
<methods>
<method name="Foo" signature="(System.Boolean)" line-rate="1" branch-rate="1">
<lines>
<line number="9" hits="2" branch="False" />
<line number="10" hits="2" branch="True" condition-coverage="100% (2/2)">
<conditions>
<condition number="4" type="jump" coverage="100%" />
</conditions>
</line>
<line number="11" hits="1" branch="False" />
<line number="13" hits="1" branch="False" />
<line number="14" hits="2" branch="False" />
</lines>
</method>
<method name="StartMassTransit" signature="()" line-rate="0" branch-rate="0">
<lines>
<line number="17" hits="0" branch="False" />
<line number="18" hits="0" branch="True" condition-coverage="0% (0/2)">
<conditions>
<condition number="12" type="jump" coverage="0%" />
</conditions>
</line>
<line number="19" hits="0" branch="False" />
<line number="20" hits="0" branch="False" />
<line number="21" hits="0" branch="False" />
<line number="22" hits="0" branch="False" />
<line number="23" hits="0" branch="False" />
<line number="24" hits="0" branch="False" />
<line number="25" hits="0" branch="False" />
<line number="26" hits="0" branch="False" />
<line number="27" hits="0" branch="False" />
<line number="28" hits="0" branch="False" />
<line number="29" hits="0" branch="False" />
<line number="30" hits="0" branch="False" />
<line number="31" hits="0" branch="False" />
... Unfortunately using collector we cannot show percentage so you need to use some tool like report generator. TL;DR; You have to use collector because when test is end rabbitMQ is slow to "close" this lead vstest plat to "kill" process. @fkucuk I think that this is the reason also for your issue...you should try this way. |
Yes, it works as you suggested. |
What does it mean?
All other reference to coverlet are unuseful. |
Ok, sounds clear. I asked because previously we didn't reference any collectors from test csproj files and |
TL;DR; Yep, coverlet tool is a simple wrapper on core instrumentation steps https://github.com/tonerdo/coverlet#how-it-works |
Thanks, I managed to get it work as needed |
I installed .net sdk 3.0.100, now I have zero coverage if I include MassTransit. My system:
Here is a sample with reproducible bug: https://gitlab.com/ittennull/coverletdemo
There is one test:
If I build the solution and run it like this:
If I comment out
service.StartMassTransit();
thenThe text was updated successfully, but these errors were encountered: