What is the difference between MSTest.TestAdapter vs MSTest.TestFramework and when do I need which one?
Solution 1
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.
Solution 2
Do you really always need to install both of them?
No. Why? (See below)
Why does it work even without the TestAdapter?
There are other adapters/runners out there that can recognize MSTest framework and that can also discover and run MSTest Framework tests.
What can I do with the TestFramework?
So in general a test framework is one used to create/author your tests while adapters/runners discover and exercise discovered tests.
When would I need this one?
There are multiple frameworks and adapters/runners and you use the one of your choosing.
Solution 3
MsTest.TestFramework contains the core framework which includes Attributes and Asserts. MsTest.TestAdapter allows us to discover the MsTest based tests and execute them. For example, identifying methods attributed with [TestMethod] and executing them.
t3chb0t
Updated on June 20, 2022Comments
-
t3chb0t almost 2 years
What is actualy the difference between
MSTest.TestAdapter
vsMSTest.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:
- Do you really always need to install both of them?
- Why does it work even without the
TestAdapter
? - What can I do with the
TestFramework
? When would I need this one?
The project page on GitHub doesn't 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.