VSTest with coverlet collector fails
See original GitHub issueI have a .NETCore 3.1 test project with "Microsoft.NET.Test.Sdk" 16.7.1
of and "coverlet.collector" 1.3.0
.
I am getting an exception when running tests using VSTest (I can’t switch to dotnet test approach, unfortunatly - there is a strong requirement to stick to vstest)
vstest.console.exe --collect:"XPlat Code Coverage" C:\Projects\test\Web.Tests\bin\Debug\Web.Tests.dll /TestAdapterPath:C:\.nuget\packages\coverlet.collector\1.3.0\build --Diag:"C:\Projects\diag.txt"
I get the following warning in the console:
Data collection : Unable to find a datacollector with friendly name 'XPlat code coverage'.
Data collection : Could not find data collector 'XPlat code coverage'
And in diag.txt file I see:
datacollector.exe, TestPluginDiscoverer: Failed to get types from assembly 'coverlet.collector, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4beb1ad7f05a1c71'. Skipping test extension scan for this assembly. Error: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginDiscoverer.GetTestExtensionsFromAssembly[TPluginInfo,TExtension](Assembly assembly, Dictionary`2 pluginInfos)
TpTrace Warning: 0 : 60664, 1, 2020/11/14, 22:42:00.029, 8944115731653, datacollector.exe, LoaderExceptions: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I followed the discussion mentioned on https://github.com/microsoft/vstest/issues/2278 but it seems like a separate issue. It feels I am missing some type of configuration.
I can’t figure out the source of the problem. Any help is highly appreciated. Thanks in advance.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:24
Top GitHub Comments
Depends on how the compilation is done…sometimes collector is copied inside bin folder(publish for instance) in some other scenario not, so to be sure to always load it you should specify
/TestAdapterPath:
when you use vstest.console.exe directly. Test platform by design search extensions in some predefined places(I don’t remember all the place) and one of these is the folder where the test container is placed, so I suspect that the coverlet extension was found here in you working sample.if you run with
dotnet test project
coverlet is injected using msbuild target and so we’re adding correct path to theTestAdapterPath
in a transparent way.can you provide a repro?It’s hard without it. Usually we need a repro and the command line.
@ManikandanMani I think that in your case the issue is that you didn’t set the
/TestAdapterPath
if used withvstest.console.exe
test platform needs to know where to discover the extensions and coverlet is not shipped together with the plat self. You should point to the folder that contains the coverlet collector like/TestAdapterPath:C:\Users\Marco\.nuget\packages\coverlet.collector\3.1.0\build\netstandard1.0