What is actualy the difference between MSTest.TestAdapter
vs MSTest.TestFramework
and when do I need which one?
In the NuGet descriptions you can read:
MSTest.TestAdapter
The adapter to discover and execute MSTest Framework based tests.
MSTest.TestFramework
This is MSTest V2, the evolution of Microsoft's Test Framework. + To discover and execute tests install MSTest.TestAdapter.
Well, not very helpful and I always install both because I'm never sure which one I should take. Strangely that in one of my test projects I only have the MSTest.TestFramework
(I guess by accident) and ReSharper still can discover tests.
My questions about these packages are:
TestAdapter
?TestFramework
? When would I need this one?The project page on GitHub does help much either. The only link
You can read more about MSTest V2 here.
navigates to a page that only says how great and open-source it is but nothing specific about either of the packages.
So Visual Studio uses a framework called Visual Studio Test Platform to load test adapters,
https://github.com/Microsoft/vstest
To discover or execute test cases, VSTest would call the test adapters based on your project configuration. (That's why NUnit/xUnit/MSTest all ask you to install a test adapter NuGet package to your unit testing projects). So MSTest.TestAdapter exists for that purposes.
MSTest.TestFramework itself implements the testing frameworks and its contracts. So you need to add a NuGet reference of it in order to write unit test cases and have them compiled. Only compiled projects along with the test adapter can then be consumed by Visual Studio.
So the final answer to your question would be "you usually need both".
The other answer from @Nkosi of course can be right if you don't ever plan to use Visual Studio. MSTest has its own command line runner, which can run your unit test project without the test adapter.