Skip to content
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

Coverlet collectors integration does not work on full framework projects #759

Closed
captainjono opened this issue Mar 16, 2020 · 8 comments
Closed
Labels
duplicate This issue or pull request already exists

Comments

@captainjono
Copy link

captainjono commented Mar 16, 2020

In practice, it seems like coverlet is only compatible with analysing .net core projects? Could someone please confirm the current compatibility of Coverlet with respect to this bug microsoft/vstest#2278

And update the project start page to reflect this would be great. I am trying to implement this on a .net full project, by calling vstest.console.exe directly with

$vstestconsolepath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\TestPlatform\vstest.console.exe"

$vsTestArguments = @(
$testDlls #.net 4.6.2
"/logger:trx"
"/InIsolation"
"/collect:"XPlat Code Coverage""
"/TestCaseFilter:" + $testCaseFilters
"/testadapterpath:" + (get-location).Path + "\packages\coverlet.collector.1.2.0\build\netstandard1.0"
)

Microsoft (R) Test Execution Command Line Tool Version 16.4.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

A total of 2 test files matched the specified pattern.
Data collection : Data collector 'XPlat Code Coverage' threw an exception during type loading, construction, or initialization: System.FormatException: Input string was not in a correct format.
   at System.Text.StringBuilder.FormatError()
   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.Format(IFormatProvider provider, String format, Object[] args)
   at Microsoft.VisualStudio.TestPlatform.Common.DataCollector.DataCollectionManager.LoadAndInitialize(DataCollectorSettings dataCollectorSettings, String settingsXml).
Data collection : Data collector 'XPlat Code Coverage' threw an exception during type loading, construction, or initialization: System.FormatException: Input string was not in a correct format.
@NPadrutt
Copy link

I have the same issue on TeamCity.

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Mar 17, 2020

Yes the collectors version of coverlet at the moment is supported only for .NET Core app and not for .NET Framework, I'm waiting some answer from vstest team(as you can see on that open issue) to understand if move to netstandard is ok or no(I think it's possible but I need confirmation), because collector was written by vstest team not by us.

@MarcoRossignoli MarcoRossignoli added the as-designed Expected behaviour label Mar 17, 2020
@MarcoRossignoli
Copy link
Collaborator

dup of #705

I'll update documentation asap.

@MarcoRossignoli MarcoRossignoli added duplicate This issue or pull request already exists and removed as-designed Expected behaviour labels Mar 17, 2020
@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Mar 17, 2020

@NPadrutt @captainjono for now the unique way to use coverlet for .NET Framework is https://github.com/tonerdo/coverlet#msbuild-integration-suffers-of-possible-known-issue and https://github.com/tonerdo/coverlet#net-global-tool-guide-suffers-of-possible-known-issue that suffer some known issue, but not all users hit the problem, because depends from the nature of code.

@MarcoRossignoli MarcoRossignoli changed the title Does not work on full framework projects Coverlet collectors integration does not work on full framework projects Mar 17, 2020
@NPadrutt
Copy link

@MarcoRossignoli Thank you! I found a blog post where he integrated it into teamcity via msbuild, so exactly what I was looking for and that worked.
https://medium.com/@justingoldberg_2282/setting-up-code-coverage-with-net-xunit-and-teamcity-for-a-solution-with-multiple-test-projects-5d0986db788b

@MarcoRossignoli
Copy link
Collaborator

Glad to hear...and sorry, I think we will support .NET Framework...but I cannot update code without green light from vstest team so I'm blocked for now on it.

@MarcoRossignoli
Copy link
Collaborator

TL;DR;

The issue is that we cannot load netcoreapp dll into .net framwork process because resolution fails, so the solution should be compile to netstandard so .net framework host(test host in this case) will load coverlet with no problem.

@NPadrutt
Copy link

thanks @MarcoRossignoli. Your effort is greatly appreciated! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants