-
Notifications
You must be signed in to change notification settings - Fork 387
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
Integrate coverlet with VSTest (Microsoft Test Platform) #395
Comments
Can we see the implementation?
We have also dotnet tool, btw integration with We're working on improving/reorganize "internals", this should lead to "stable"(cross finger) interface/contracts usable "outside" as standalone api. cc: @tonerdo |
@MarcoRossignoli Adding implementation details. Scenario Explanation :
Asks :
|
Some questions(so you can save me/us some time on docs):
What "results" should send?Coverage output file i.e. cobertura file etc...?
How versioning works?I mean if we publish collector package and we need to update(collector self or some transient dependencies) due to bug fix new features, is unit test projects template versionable?
It's not clear to me why/when use InProcess collector vs out of process one( |
Thanks for elaborating @vagisha-nidhi. I'm happy you're looking to make Coverlet part of the out of the box experience, we definitely intend to work through this with you. Your implementation details seem fine to me. However, I have a few of questions:
How will users pass extra arguments like coverage format, threshold etc.
Can this be called
What's the difference between an in-proc and out-of-proc datacollector? How does one create both? Which one do we need to make this integration work? |
I believe it'll be the coverage output file. See here: https://github.com/Microsoft/vstest-docs/blob/master/docs/extensions/datacollector.md#datacollectionsink |
It will be the coverage output file.
There's no versioning for the test template. If a new collector package is pushed, the template will be updated with the newer version. The existing users can update the nuget package to get the latest changes.
We will need both the collectors. The inproc collector (which runs in the testhost process) is needed for the flushing of the hit files to be reliable and not dependent on the exit handler. The outproc collector is needed to setup the test session (instrument the dlls) |
Thanks @tonerdo and @MarcoRossignoli for reviewing the enhancement and the comments. We are excited to work with you to enable this integration as it would address the code coverage ask in a seamless way with dotnet test/vstest.
There are options to pass runsettings information through cmdline. https://github.com/Microsoft/vstest-docs/blob/master/docs/configure.md. This doesn't work well for datacollector settings under which the coverage format, threshold would fall under. As of now these options would need a runsettings file to specify a value other than the default. We will look addressing the gap here.
Yes.
The inproc data collector runs in the testhost process executing the tests (testhost*.exe/ testhost.dll). The outproc collector would run in a separate process (datacollector.exe/datacollector.dll). We would need the inproc collector to remove the dependency on the exit handler to flush the hits and would need the outproc collector to setup the test run session (instrument dlls) and restore. |
To start to work on it could be good if some of you(MS guys) write a documentation guide under |
@MarcoRossignoli That would be a great start. I'll shortly raise a PR on the repo with the documentation. We can discuss the next steps further. |
@vagisha-nidhi What is missing here and when will we be able to try this out with dotnet test? |
@MarcoRossignoli @tonerdo dotnet sdk version 2.2.300 has been released. You can download it from https://dotnet.microsoft.com/download/dotnet-core/2.2 and try it out. Then we should be able to release the nuget. |
I'll do test ASAP, I found also an issue, on coverlet.core we use Newtownsoft.Json 9.x.x but this version has got a bug and doesn't use converter in a correct way...we didn't hit issue on test because seem that msbuil load version 10.x.x and not referenced one. What does vstest runner load?I'll upgrade to 10.x.x on next PR(I'm working on custom runner for instrumentation tests) |
@vagisha-nidhi @tonerdo doing some tests:
C:\Users\Marco\Downloads\TMP\TMP\XUnitTestProject1
λ dotnet test --collect:"XPlat Code Coverage"
Test run for C:\Users\Marco\Downloads\TMP\TMP\XUnitTestProject1\bin\Debug\netcoreapp2.2\XUnitTestProject1.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 16.1.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Attachments:
C:\Users\Marco\Downloads\TMP\TMP\XUnitTestProject1\TestResults\57f654f2-7b66-41d1-aa2d-7f0ba8b8df09\coverage.cobertura.xml
Test Run Successful.
Total tests: 1
Passed: 1
Total time: 2,2419 Seconds
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>json</Format>
<!--<MergeWith>/custom/path/result.json</MergeWith>
<Exclude>[coverlet.*.tests?]*,[*]Coverlet.Core*</Exclude> --><!-- [Assembly-Filter]Type-Filter --><!--
<Include>[coverlet.*]*,[*]Coverlet.Core*</Include> --><!-- [Assembly-Filter]Type-Filter --><!--
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
<ExcludeByFile>../dir1/class1.cs,../dir2/*.cs,../dir3/**/*.cs,</ExcludeByFile> --><!-- Absolute or relative file paths --><!--
<IncludeDirectory>../dir1/*,../dir2/,</IncludeDirectory>
<SingleHit>false</SingleHit>
<UseSourceLink>true</UseSourceLink>-->
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
Doing some investigation. |
@MarcoRossignoli Rooted down the cause. This is happening because of the * character in |
@vagisha-nidhi strange...I didn't passed that param...I'm using an empty on like <?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>json</Format>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings> |
@vagisha-nidhi never mind...I used wrong settings, your analysis is correct. |
@MarcoRossignoli Yeah. First of all, we should update the documentation so that nobody faces it if they are directly using the runsettings from what written in the documentation. |
@MarcoRossignoli Also, dotnet vstest scenario won't work with this release of sdk. It will be available with the next release. |
@vagisha-nidhi let me do some other tests to undestand why that config worked in past...after that I'll update the docs. |
My tests are ok, some logs <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.0" />
<PackageReference Include="coverlet.collector" Version="1.0.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="..\TMP\TMP.csproj" />
</ItemGroup>
</Project>
C:\Users\Marco\Downloads\TMP\TMP
λ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.2.300
Commit: 73efd5bd87
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.300\
Host (useful for support):
Version: 3.0.0-preview5-27626-15
Commit: 61f30f5a23
.NET Core SDKs installed:
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.504 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.1.600 [C:\Program Files\dotnet\sdk]
2.1.601 [C:\Program Files\dotnet\sdk]
2.1.602 [C:\Program Files\dotnet\sdk]
2.1.700-preview-009597 [C:\Program Files\dotnet\sdk]
2.1.700-preview-009601 [C:\Program Files\dotnet\sdk]
2.1.700-preview-009618 [C:\Program Files\dotnet\sdk]
2.2.104 [C:\Program Files\dotnet\sdk]
2.2.203 [C:\Program Files\dotnet\sdk]
2.2.204 [C:\Program Files\dotnet\sdk]
2.2.300 [C:\Program Files\dotnet\sdk]
3.0.100-preview5-011568 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview5-19227-01 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview5-27626-15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview5-27626-15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
C:\Users\Marco\Downloads\TMP\TMP
λ dotnet test --collect:"XPlat Code Coverage"
Test run for C:\Users\Marco\Downloads\TMP\TMP\XUnitTestProject1\bin\Debug\netcoreapp2.2\XUnitTestProject1.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 16.1.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Attachments:
C:\Users\Marco\Downloads\TMP\TMP\XUnitTestProject1\TestResults\45f3df8e-5657-4c91-b56e-98b196728d9e\coverage.cobertura.xml
Test Run Successful.
Total tests: 1
Passed: 1
Total time: 2,1578 Seconds
C:\Users\Marco\Downloads\TMP\TMP
λ dotnet test --settings coverletArgs.runsettings
Test run for C:\Users\Marco\Downloads\TMP\TMP\XUnitTestProject1\bin\Debug\netcoreapp2.2\XUnitTestProject1.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 16.1.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Attachments:
C:\Users\Marco\Downloads\TMP\TMP\XUnitTestProject1\TestResults\481a7d4c-73e4-4b4a-8fe6-992e45fda824\coverage.json
Test Run Successful.
Total tests: 1
Passed: 1
Total time: 1,7576 Seconds
C:\Users\Marco\Downloads\TMP\TMP
λ <?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>json</Format>
<MergeWith>/custom/path/result.json</MergeWith>
<Exclude>[coverlet.*.tests?]*,[*]Coverlet.Core*</Exclude>
<Include>[coverlet.*]*,[*]Coverlet.Core*</Include>
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
<ExcludeByFile>../dir1/class1.cs,../dir2/*.cs,../dir3/**/*.cs,</ExcludeByFile>
<IncludeDirectory>../dir1/,../dir2/,</IncludeDirectory>
<SingleHit>false</SingleHit>
<UseSourceLink>true</UseSourceLink>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings> Simple test code: namespace XUnitTestProject1
{
public class UnitTest1
{
[Fact]
public void Test1()
{
Class1 c = new Class1();
c.Test();
}
}
}
...
namespace TMP
{
public class Class1
{
public void Test()
{
}
}
} I think that we could publish cc: @tonerdo @vagisha-nidhi |
@MarcoRossignoli |
Awesome. Will make a release within 24 hours |
@vagisha-nidhi before add reference I would like to do some tests with nuget package...only to be sure that all it's ok, for the sake. |
@MarcoRossignoli Sure. Let me know about that. |
@tonerdo just a moment maybe we missed one feature from collectors But no on collector https://github.com/tonerdo/coverlet/blob/master/src/coverlet.collector/DataCollection/CoverletCoverageCollector.cs#L139 we send only artifact. @tonerdo if you want to setup and publish something, publish a Bonus: we should setup a nighly build...I expect an increase in usage if MS will advertise this we should join beta of https://devblogs.microsoft.com/devops/pay-per-gb-azure-artifacts/ |
@MarcoRossignoli @tonerdo |
@MarcoRossignoli |
@vagisha-nidhi @tonerdo if it's not "fully supported" by test plat at the moment I'm ok with release this version, we'll support it in future based on user feedback, we can release package! |
@tonerdo @MarcoRossignoli I think we can go ahead with releasing the nuget. I have done some testing from my side as well. |
Toni! |
@vagisha-nidhi @MarcoRossignoli do you think I should release it as a pre-release beta or is stable enough for a |
One step a time? Plan could be, beta1->nighly build(Toni I told you my idea offline) -> bug fix/new features -> nighly(for users)-> betaN or stable. cc: @vagisha-nidhi |
@tonerdo @MarcoRossignoli A beta package is good enough for people to get their hands on. Plus we'll be able to know if there is any major issue that we should fix right away. |
@tonerdo @MarcoRossignoli |
Green light to me we've nightly https://www.myget.org/feed/coverlet-dev/package/nuget/coverlet.collector (no perfect yet but enough in case of issue, we're fixing version to be more user friendly inside VS)
https://docs.microsoft.com/en-us/nuget/create-packages/prerelease-packages#semantic-versioning
We could release also pre-release directly from master for simplicity and avoid to commit add and removal of |
I'm hitting a missing method exception when I try to use it, details here: #456 |
One other thing -- from a docs perspective, the I think that's an important parameter and it could help to make it more clear with some concrete examples. |
@onovotny thank's for the feedback I opened a new issue #457, feel free to open new issue if find lack in documentations. |
@MarcoRossignoli @tonerdo Also, to pick up inproc datacollector, we had changes in test host that comes via Never the less, this won't affect the outproc datacollector(only that it needs sdk>=2.2.300). cc: @PBoraMSFT |
Clear...recap to run in/out collectors we need to run >=2.2.300 SDK and reference test sdk >= 16.1.0 |
@MarcoRossignoli Should we add cc: @cltshivash |
I think the more 80% likely defaults and "right thing" should be defaulted, fwiw, so I'd say yes. I would also suggest it exclude |
I'll move to new issue with my thoughts. |
Done |
What would integrating Coverlet with Microsoft Test Platform mean:
Edit: Fixed markdown typos. I was referring to bullet 1 in the above description, not the issue number.
The text was updated successfully, but these errors were encountered: