0

I have been using MSTest's [TestMethod] and similar attributes to setup unit tests for many, many years... work just fine for my needs.

I recently upgraded one of my class libs to .NET Standard 2.0, which required me to upgrade my project files to the new format. And I similarly updated my test project file for that library so that I could multi-target the tests (both net462 and net5.0-windows). That seemed to work great as it builds just fine and the TestExplorer window shows my 19 Test Methods just as it used to, but now repeated twice, once for each target. Perfect. So, I press "Run All" and it changes them all to little clock icons just like it used to, but then... nothing... it never runs them. Just turns them back to "not run" blue. Putting a breakpoint at the front of the tests' initialization show they never run at all.

Here's the text output it gives:

========== Starting test run ==========

[MSTest][Discovery][C:\tcc\Development\Common\Test\CommonTest\bin\Debug\net462\CommonTest.dll] Failed to discover tests from assembly C:\tcc\Development\Common\Test\CommonTest\bin\Debug\net462\CommonTest.dll. Reason:Could not load type 'Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope' from assembly 'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. No test matches the given testcase filter FullyQualifiedName=CommonTest.SerializableHashtableTest.TestEmptySerialization|FullyQualifiedName=CommonTest.SerializableHashtableTest.TestNestedSerialization|FullyQualifiedName=CommonTest.SerializableHashtableTest.TestSimpleSerialization|FullyQualifiedNam... in C:\tcc\Development\Common\Test\CommonTest\bin\Debug\net462\CommonTest.dll An exception occurred while invoking executor 'executor://mstestadapter/v2': Could not load type 'Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope' from assembly 'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Stack trace: at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor.RunTests(IEnumerable1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.RunTestsWithSources.InvokeExecutor(LazyExtension2 executor, Tuple2 executorUriExtensionTuple, RunContext runContext, IFrameworkHandle frameworkHandle) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.RunTestInternalWithExecutors(IEnumerable1 executorUriExtensionMap, Int64 totalTests)

========== Test run finished: 0 Tests (0 Passed, 0 Failed, 0 Skipped) run in 46 ms ==========

In response to that, I added NuGet package "Microsoft.VisualStudio.TestPlatform" and later "Microsoft.TestPlatform" that is actually from Microsoft, restarted VS, rebuilt, and re-ran the tests, but still nothing. I have these 4 NuGet packages installed at this point (not sure which, if any, were actually needed/helpful):

Microsoft.TestPlatform (16.11.0) (also tried Microsoft.VisualStudio.TestPlatform)

Microsoft.NET.Test.Sdk (16.11.0)

Microsoft.UnitTestFramework.Extensions (2.0.0)

MSTest.TestAdapter (2.2.7)

Visual Studio 2019 (16.11.2)

This old StackOverflow thread: Visual Studio 15.8.1 not running MS unit tests suggested a setting under the Test Options, but that setting is no longer a thing in Visual Studio 2019.

I don't understand the "didn't discover any tests" part of that... it clearly found all 19 of my TestMethod's, and displays them hierarchically organized just like it always did.

Any other suggestions? (I have hundreds of these unit tests, so rewriting them in some other test framework like NUnit or xUnit is not too appealing.)

UPDATE #1:

Per Zdeněk's project file, I added MSTest.TestFramework package and it started running the net5.0-windows targeted tests; but for the net462 targeted tests, it is still doing the return from clock icon to blue "Not Run" icon. So, then I tried targeting it for JUST net462... still won't run it. Is there a different package needed to run .NET Framework targeted tests with new-style project files?

Here's my Project file (with the single-targeted alternatives that I've tried commented out):

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net462;net5.0-windows</TargetFrameworks>
    <!-- <TargetFramework>net462</TargetFramework> -->
    <!-- <TargetFramework>net5.0-windows</TargetFramework> -->
    <UseWindowsForms>true</UseWindowsForms>
    <Title>CommonTest</Title>
    <Description>Unit Test code for Tcc.Common library.</Description>
    <Product>CommonTest</Product>
    <Company>Targeted Convergence Corporation</Company>
    <Copyright>Copyright © Targeted Convergence Corporation 2005-2021</Copyright>
    <AssemblyVersion>1.0.0.0</AssemblyVersion>
    <FileVersion>1.0.0.0</FileVersion>
    <InformationalVersion>1.0.0.0</InformationalVersion>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="log4net" Version="2.0.12" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
    <PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
    <PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
    <PackageReference Include="System.Drawing.Common" Version="5.0.2" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\Source\tcc.common\Tcc.Common.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="Image\huge.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Update="Image\logo.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Update="Image\logo.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Update="Image\pano.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Update="Image\small.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>

UPDATE #2:

As requested by Zdeněk, dotnet test appears to find the tests for both targets:

C:\tcc\Development\Common\Test\CommonTest>dotnet test --list-tests
  Determining projects to restore...
  Restored C:\tcc\Development\Common\Source\tcc.common\Tcc.Common.csproj (in 438 ms).
  Restored C:\tcc\Development\Common\Test\CommonTest\CommonTest.csproj (in 672 ms).
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  Tcc.Common -> C:\tcc\Development\Common\Source\tcc.common\bin\Debug\netstandard2.0\Tcc.Common.dll
  CommonTest -> C:\tcc\Development\Common\Test\CommonTest\bin\Debug\net5.0-windows\CommonTest.dll
  CommonTest -> C:\tcc\Development\Common\Test\CommonTest\bin\Debug\net462\CommonTest.dll
Test run for C:\tcc\Development\Common\Test\CommonTest\bin\Debug\net462\CommonTest.dll (.NETFramework,Version=v4.6.2)
Microsoft (R) Test Execution Command Line Tool Version 17.0.0-preview-20210715-01
Copyright (c) Microsoft Corporation.  All rights reserved.
 
The following Tests are available:
    TestGenSmallEmfFile
    TestComposeMetafiles
    TestImageFormatSizes
    TestMetafileContainingBitmap
    TestImageFromStream
    TestEmptySerialization
    TestSimpleSerialization
    TestNestedSerialization
    TestSpeeds
    TestIPAddresses
Test run for C:\tcc\Development\Common\Test\CommonTest\bin\Debug\net5.0-windows\CommonTest.dll (.NETCoreApp,Version=v5.0)
Microsoft (R) Test Execution Command Line Tool Version 17.0.0-preview-20210715-01
Copyright (c) Microsoft Corporation.  All rights reserved.
 
The following Tests are available:
    TestGenSmallEmfFile
    TestComposeMetafiles
    TestImageFormatSizes
    TestMetafileContainingBitmap
    TestImageFromStream
    TestEmptySerialization
    TestSimpleSerialization
    TestNestedSerialization
    TestSpeeds
    TestIPAddresses
 
C:\tcc\Development\Common\Test\CommonTest>dotnet --version
6.0.100-preview.7.21379.14
 
C:\tcc\Development\Common\Test\CommonTest>dotnet --list-sdks
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.526 [C:\Program Files\dotnet\sdk]
5.0.400 [C:\Program Files\dotnet\sdk]
6.0.100-preview.7.21379.14 [C:\Program Files\dotnet\sdk]

UPDATE #3:

So, after getting the MSTest.TestFramework package in there, the VS Output window under "Tests" shows the following Exception. I tried adding package System.Collections.Concurrent to my CommonTest project, but that did not help... same output. It is like the Visual Studio developers forgot to add that package to their build. Here's the Tests output with the exception and call stack:

========== Starting test discovery ==========
========== Test discovery finished: 20 Tests found in 2.1 sec ==========
========== Starting test run ==========
An exception occurred while invoking executor 'executor://mstestadapter/v2': Exception has been thrown by the target of an invocation.
Stack trace:
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
   at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.AppDomainUtilities.CreateInstance(AppDomain appDomain, Type type, Object[] arguments)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestSourceHost.CreateInstanceForType(Type type, Object[] args)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTestsInSource(IEnumerable`1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle, String source, Boolean isDeploymentDone)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTests(IEnumerable`1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle, Boolean isDeploymentDone)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.RunTests(IEnumerable`1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle, TestRunCancellationToken runCancellationToken)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor.RunTests(IEnumerable`1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.RunTestsWithTests.InvokeExecutor(LazyExtension`2 executor, Tuple`2 executorUri, RunContext runContext, IFrameworkHandle frameworkHandle)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.<>c__DisplayClass48_0.<RunTestInternalWithExecutors>b__0()
   at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.PlatformThread.<>c__DisplayClass0_0.<Run>b__0()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.PlatformThread.Run(Action action, PlatformApartmentState apartmentState, Boolean waitForCompletion)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.TryToRunInSTAThread(Action action, Boolean waitForCompletion)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.RunTestInternalWithExecutors(IEnumerable`1 executorUriExtensionMap, Int64 totalTests)
 
Inner exception: Could not load file or assembly 'System.Collections.Concurrent, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
 
Stack trace:
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TypeCache..ctor(ReflectHelper reflectionHelper)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner..ctor(MSTestSettings settings)
 
========== Test run finished: 10 Tests (10 Passed, 0 Failed, 0 Skipped) run in 43.8 sec ==========
========== Starting test run ==========
An exception occurred while invoking executor 'executor://mstestadapter/v2': Exception has been thrown by the target of an invocation.
Stack trace:
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
   at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.AppDomainUtilities.CreateInstance(AppDomain appDomain, Type type, Object[] arguments)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestSourceHost.CreateInstanceForType(Type type, Object[] args)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTestsInSource(IEnumerable`1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle, String source, Boolean isDeploymentDone)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTests(IEnumerable`1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle, Boolean isDeploymentDone)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.RunTests(IEnumerable`1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle, TestRunCancellationToken runCancellationToken)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor.RunTests(IEnumerable`1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.RunTestsWithTests.InvokeExecutor(LazyExtension`2 executor, Tuple`2 executorUri, RunContext runContext, IFrameworkHandle frameworkHandle)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.<>c__DisplayClass48_0.<RunTestInternalWithExecutors>b__0()
   at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.PlatformThread.<>c__DisplayClass0_0.<Run>b__0()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.PlatformThread.Run(Action action, PlatformApartmentState apartmentState, Boolean waitForCompletion)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.TryToRunInSTAThread(Action action, Boolean waitForCompletion)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.RunTestInternalWithExecutors(IEnumerable`1 executorUriExtensionMap, Int64 totalTests)
 
Inner exception: Could not load file or assembly 'System.Collections.Concurrent, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
 
Stack trace:
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TypeCache..ctor(ReflectHelper reflectionHelper)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner..ctor(MSTestSettings settings)
 
========== Test run finished: 0 Tests (0 Passed, 0 Failed, 0 Skipped) run in 2.8 sec ==========

NOTE: Running these tests via 'dotnet test' works fine... all run... all pass... under both net462 and net5.0-windows.

Brian Kennedy
  • 3,499
  • 3
  • 21
  • 27
  • Could you please also specify the versions of the testing NuGets? – Zdeněk Jelínek Sep 04 '21 at 06:09
  • 2
    What I'd do is create a new MSTest project, ideally 4.6.2-targeted and see if it works. If it does, try to add .net 5. If it still works, check out the differences with your actual testing project. If it does not work somewhere along the road, you have a minimal repro. It is quite hard to guess the issue from a complicated, non-reproducible scenario that you are facing. – Zdeněk Jelínek Sep 04 '21 at 06:23
  • Version numbers added. Trying it not multi-targeted is a good idea... just tried it with only net462... same behavior (but with just the 19, rather than 2*19). Seems there's some default filtering that filters away everything?!? Seems stupid, but then a lot of this new stuff seems so. Thanks. – Brian Kennedy Sep 04 '21 at 07:46
  • Also tried it with VS 2022 Preview 3... same behavior. --sigh-- The nice thing about MS Test was it just worked as-is, built into the default VS. – Brian Kennedy Sep 04 '21 at 13:03
  • Since you've made updates, I'll respond here. Does that mean that `dotnet test` runs the tests? That would mean there's an issue with VS and how it runs the tests. Your original log already has some filters but I don't believe that any such tests exist in the project, at least not in the discovery you have posted. Could you double check that, possibly with higher verbosity to check where the filter value comes from, especially if it does not match your VS selection? – Zdeněk Jelínek Sep 06 '21 at 18:25
  • I don't know if dotnet test runs the tests... I certainly haven't overridden it to do otherwise... I haven't set up any filters... VS lists all the tests for both platforms, turns both lists to watches, but then just never runs the 462 tests. I just created a project using the TestClass and TestMethod attributes and VS Test Explorer has always run them just fine... until I switched to the new style project file. I'm not sure how to double-check it... I'm happy to run any commands you ask for though. – Brian Kennedy Sep 06 '21 at 19:12
  • 1
    Well if you run `dotnet test` does it run the tests, including net462? If I'm not mistaken it should show a summary. Or there should be some flag to do it, check the docs. Also, you have posted text output of tests of some sort. It mentions not being able to load types which should now be repaired as you fixed the package references in your project, so I was wondering if that output changed as a result. – Zdeněk Jelínek Sep 06 '21 at 19:42
  • Ah, yes... doing 'dotnet test' does indeed run the tests for both (net462 included) and all 10 tests pass. In contrast, looking in the Tests Output in VS, it does indeed give some new info... the MSTest.TestFramework throws exception as it is unable to load the file System.Collections.Concurrent. So, I added that package, but it seems to fix nothing. See UPDATE #3 for the exception message and call stack. – Brian Kennedy Sep 06 '21 at 20:53
  • Does the test output change in any way when you change Logging level to diagnostic or trace in Options > Test? If yes, is there anything that could relate to the tests not being found or a strange test filter coming from somewhere? I don't believe that the concurrent collections load is the root cause as that would have reproduced under dotnet CLI as well. If the test output does not change, I see no other way to help you unless you make MCVE out of this, I cannot reproduce the issue with the csproj file you posted. – Zdeněk Jelínek Sep 07 '21 at 20:35

2 Answers2

2

I have just created a .NET Core 3.1 MS Test project, changed it to .NET Framework 4.6.1, fought for a while with VS which I attribute to using VS 2022 Preview and ReSharper, added .NET 5.0 and it works.

csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>net461;net5-windows</TargetFrameworks>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
    <PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
    <PackageReference Include="coverlet.collector" Version="3.0.2" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Dummy.Netstandard20.Library\Dummy.Netstandard20.Library.csproj" />
  </ItemGroup>
</Project>

Unit tests:

using Dummy.Netstandard20.Library;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTestProject2
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            new Class1(); // Comes from Dummy.Netstandard20.Library
        }
    }
}

If this does not work for you, it would be great if you opened a new question and detail exactly what your minimal reproducible csproj, unit test and output log look like. Also your .NET CLI and SDK versions would be great (dotnet --version, dotnet --list-sdks).

There could also be issues with discovery. Nobody can tell unless you provide something reproducible.

Zdeněk Jelínek
  • 2,611
  • 1
  • 17
  • 23
  • Thanks for that... it allowed me to see that I needed to add package MSTest.TestFramework instead of Microsoft.TestPlatform and Microsoft.UnitTestFramework.Extensions that others have recommended. That got it running all the tests under the net5.0-windows target... but the tests under the net462 target still go to a clock and then just back to blue "Not Run" symbol. Any ideas on how to fix that? (Yes, I'll try whittling this down to something I can post; but that won't be easy... 10 years of unit tests here.) – Brian Kennedy Sep 06 '21 at 12:52
  • NOTE: I tried targeting just net462... same "Not Run" result... so, it is not the multi-targeting, but rather trying to target .NET Framework from a new-style project file? I added my .csproj project file to my post above, in case you can see some mistake I am making. – Brian Kennedy Sep 06 '21 at 13:53
  • 1
    That would be symptomatic of test doscovery issue. Do your tests discover when you use `dotnet test --list-tests`? – Zdeněk Jelínek Sep 06 '21 at 18:01
  • Yes, the tests are discovered for both targets... see the output of that and the other dotnet commands you mentioned in UPDATE #2 above. – Brian Kennedy Sep 06 '21 at 18:19
  • P.S. I have VS 2017, VS 2019, and VS 2022 preview 3 all installed. I primarily use VS 2019 for production code. I am experimenting with VS 2022... in particular when trying to convert things to .NET 5 and soon .NET 6. – Brian Kennedy Sep 06 '21 at 18:23
1

I just ran into the same issue, with the same System.Collections.Concurrent errror in the Test logs, and solved it by changing the test project's target framework from net462 to net48. I know .NET Framework 4.7.x had quite a few fixes to how binding redirects work, so that's probably the explanation.

IGx89
  • 872
  • 7
  • 18