39

I noticed a change in one of our solutions in VS 2015 today. It seems the test projects that are generated for the solution use a different namespace than the existing test projects in the same solution.

Only the test projects that reference

Microsoft.VisualStudio.QualityTools.UnitTestFramework

are recognized as test projects within Visual Studio 2015.

However there are now some test projects referencing

Microsoft.VisualStudio.TestPlatform.TestFramework Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions

It's possible that these test project where generated from VS 2017 RC. This would explain the different namespace. I didn't find any docs about backward compatibility.

Question is, which namespace to use? As we can't use both namespaces at the same time. What are the differences between the two namespaces?

VisualStudio 2015 is able to build the test projects with either reference. To switch the newer namespace back to the older namespace only because of the test project generation is not reason enough I think.

SwissCoder
  • 2,514
  • 4
  • 28
  • 40
  • 1
    Thank you, I just realized that the unit test generator is the one from ReSharper. It looks the same as the intelliTest test generator which is only available in VS Enterprise. So it seems I have to configure resharper to somehow use mstest 2.0. if that is possible. Thanks a lot for the hint. – SwissCoder Mar 06 '17 at 09:53

1 Answers1

23

MSTest has been released as a new NuGet package solution that is no longer tightly coupled to the Visual Studio version. Your new projects are using MSTest 2.0.

MSTest V2 release annoucement: https://devblogs.microsoft.com/devops/taking-the-mstest-framework-forward-with-mstest-v2/

riQQ
  • 9,878
  • 7
  • 49
  • 66
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • I'm very confused now ... the post lists *yet another* set of namespaces than the ones from the question: `Microsoft.VisualStudio.TestTools.UnitTesting` and `Microsoft.VisualStudio.TestPlatform.UnitTestFramework` apparently being *old*, while, according to your answer, they should be *new* and referring to MSTest 2.0. The linked release announcement points out MSTest 2.0's namespace should be `Microsoft.VisualStudio.TestTools.UnitTesting`. Or did I misinterpret anything there? – O. R. Mapper Nov 17 '20 at 14:34
  • Use the NuGets. Stick to those. Easiest way is to delete all the references and add the nuget. It will add the right assemblies and intellisensi will tell you what to use. – jessehouwing Nov 17 '20 at 18:57
  • 1
    That strategy isn't helpful if you'd like to understand what you're doing, or when you need to get existing code to run as it is without changing it. – O. R. Mapper Nov 17 '20 at 20:00
  • The assemblies being referenced are part of Visual Studio (pre 2015), and they changed... By keeping the older version of Visual Studio installed and explicitly referencing the old assemblies, the code will build, but it may not be detected by the Visual Studio Test Runner in Visual Studio 2015 and above. – jessehouwing Nov 18 '20 at 09:28
  • Uh-oh, not conductive to sharing code in a team with heterogenous software environments. – O. R. Mapper Nov 18 '20 at 11:32
  • 1
    True. You can always choose to keep using VS2013. But that's 7 years old now and a lot has changed. Infinite backwards compatibility would have withheld a lot of progress. The changes are minor and once done will likely speed up your test cycle as well. – jessehouwing Nov 18 '20 at 11:42