-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why is the test host not part of the test framework? #3090
Comments
It would probably take few pages of context to answer fully, but in short, there are some historical reasons and there are some architectural reasons. To run tests via test platform we need a testhost, an adapter that adapts the test framework to test platform, and the test framework itself. Line between those packages are a bit blurry for MSTest because it is always used with Test platform (and VS) that I know of. But take a different test framework, for example XUnit. Xunit can be used with their own xunit console runner that is specific to xunit, as well as with test platform. To integrate with test platform there is xunit.visualstudio.runner package which adapts xunit for the use with TP (and VS). That adapter could take dependency on Microsoft.NET.Test.SDK and all might be good, we could also add the same dependency for MSTest.TestAdapter. We would not take the dependency in MSTest.TestFramework, the same way xunit would not take that dependency in their "core" xunit package. What is other stuff in the test.sdk package? Not much, just the dependency on testhost package (that has the dll and executables for testhost, and it's dependencies), and targets that automatically generate Program.cs with Main for your app, because the test project needs to be executable, so we know what dependencies it has, and how to run it as a given tfm. Lastly, there is now this PR, which is a new fallback if you are missing the test.sdk package, it's not perfect, and it's main goal is to enable cpp tests to run under .net (core) testhost, but it adds all the pieces you would normally get from Microsoft.NET.Test.SDK and it's dependencies into dotnet SDK so your project would be able to run even without it: #3003 |
Thank you very much for such a detailed answer. It totally makes sense that in case of another framework. e.g. xUnit, the SDK / Host would be the same but the framework and adapter would be different, so you basically need to split the framework and SDK into two different packages. |
Np. We are actively looking into making this simpler for users. But there are many competing factors. Personally, in the end I would love to have just a MSTest package that is installed via the template, that would depend on MSTest.TestFramework, and MSTest.TestAdapter. And MSTest.TestAdapter would then depend on Microsoft.NET.Test.SDK. This would simplify the installation and avoid common errors, like Test.SDK not being in sync with MSTest or the two MSTest packages not being in sync. |
I was struggling with some tests until I found out I was missing a reference to the Microsoft.Net.Test.Sdk package which contains the TestHost.dll. Now I'm wondering why this is not part of the MSTest.TestFramework package?
What else is part of the Microsoft.NetTest.Sdk package?
Because I can write & compile tests by using only the MSTest.TestFramework and MSTest.TestAdapter packages, but I can't run them because for the test host to be available the Microsoft.NetTest.Sdk package has to be installed.
The text was updated successfully, but these errors were encountered: