vstest icon indicating copy to clipboard operation
vstest copied to clipboard

Discovery incorrectly uses all adapters for all test projects

Open clairernovotny opened this issue 9 years ago • 2 comments

It appears that VS Test is wrongly calling the xUnit discovery process on a library that doesn't have the vs adapter package dependency. This leads to discovery and execution time failures because we have a dependency on DependencyModel 1.1 and the MSTest library doesn't.

To repro,

Clone https://github.com/onovotny/XUnitTestProject1-Test check out commit 05ca3a4a05103493f00ab22bc5d42a84ab2abffd

Build the solution in VS 2017 RC4.

Look at the test window and you'll see

------ Discover test started ------
[xUnit.net 00:00:00.0084606] Exception discovering tests: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyModel, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.Extensions.DependencyModel, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner.GetAvailableRunnerReporters(IEnumerable`1 sources)
   at Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner.GetRunnerReporter(IEnumerable`1 assemblyFileNames)
   at Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner.DiscoverTests[TVisitor](IRunSettings runSettings, IEnumerable`1 sources, LoggerHelper logger, Func`4 visitorFactory, Action`4 visitComplete)
========== Discover test finished: 2 found (0:00:00.8784832) ==========

If you clear the tests output and then just rebuild the UnitTestProject project (the MSTest, not xunit), you'll see that in the test output window.

There's no reason our adapter should be getting invoked for a library that doesn't reference it.

/cc @bradwilson

clairernovotny avatar Feb 16 '17 20:02 clairernovotny

This is being tracked external to this repo here: https://developercommunity.visualstudio.com/content/problem/145931/discovery-incorrectly-uses-all-adapters-for-all-te.html

snkota avatar Nov 07 '17 12:11 snkota

Does not repro on latest VS2017.5 Microsoft.Net.Test.SDK 15.5.0, & latest Xunit / MStest Adapters

mayankbansal018 avatar Nov 21 '17 07:11 mayankbansal018