You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.NET Workaround for mixing MTP and vstest projects in a solution #6484
Current documentation says that cannot mix MTP and vstest based tests in a solution. Does this apply to the dotnet test project only, or on loading tests in VS too?
I have a large solution with 90-100 test projects. I would like to introduce MTP and gradually migrate to it, but I can only do it project by project due to the scale.
Proposed Feature
Have a dotnet test switch to allow running only vstest or MTP tests. (I could run dotnet test commands for different parts of the solution)
Make filtering work - can I filter out projects/tests by category etc. that belong to one or another test runner to be able to mix MTP and vstest projects?
Can I create a temporary sln just for the tests? (but in VS I would need to load all test projects)
Alternative Designs
Any other workaround or suggestion that I have not thought about.
Is this a limitation only on dotnet test or other tools as well? Does the dotnet run command work well on a solution?
Should I create individual dotnet test commands for each migrated project?
If there is a workaround / suggested workaround, could you document it?
Time and effort. This is a task someone can work through part by part, say over a few weeks period. Some of the tests use xunit, some mstest, they need to support different output formats, coverage formats etc.
For example, as I see JUnit.TestLogger is not yet supported, and some of the test projects need it (because of an integration with source control - in this case gitlab, which only handles junit). But other test projects that do not need junit.testlogger could be already migrated.
Same story with test coverage and making test coverage work on GitLab and on Sonarqube, etc. Some projects can be done, and some cannot.
Time and effort. This is a task someone can work through part by part, say over a few weeks period. Some of the tests use xunit, some mstest, they need to support different output formats, coverage formats etc.
In the ideal scenario, you'd be able to add <EnableMSTestRunner>true</EnableMSTestRunner> and <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner> in Directory.Build.props, then all your MSTest and xUnit projects are MTP. The only remaining step will be to add <OutputType>Exe</OutputType> to all your test projects. But whether or not you can add OutputType in a centralized place depends very much on your exact scenario.
For coverage, I think easiest is to align all your projects to use Microsoft.Testing.Extensions.CodeCoverage. Whether or not this is easy might depend on your specific case.
For JUnit logger, I think xUnit.net has built-in support for junit using --report-junit, so you don't really need JUnit.TestLogger for xUnit projects. For MSTest projects, there is no built-in support for JUnit logging. This is tracked by #4268, or we could try to get JUnit.TestLogger to support MTP, finish #4268, or maybe xUnit.net could consider separating the junit support outside of xunit to be a generic MTP extension? cc Brad Wilson (@bradwilson)
To answer specifically about mixing VSTest and MTP in the same solution, this is not a supported scenario for dotnet test. However, if you are able to make two solution filters, one which is completely MTP and the other is completely VSTest, you can invoke dotnet test twice on each filter. However, keep in mind that with .NET 10 SDK, you will need to adjust dotnet.config before running each dotnet test invocation.
For Visual Studio, this mixing MTP and VSTest works perfectly fine today AFAIK. But looping in Artur Spychaj (@drognanar) to confirm whether or not it's a supported scenario.
maybe xUnit.net could consider separating the junit support outside of xunit to be a generic MTP extension?
I definitely believe somebody should own reporters in JUnit, NUnit, and CTRF format. That work could be based on the code that's in xUnit.net, but we obviously can't just replace our code with MTP extensions, since we also support running in non-MTP mode. What's also not clear to me is how much additional information would need to be made available beyond the basic model (much the same way that TRX requires test frameworks to implement additional data).
The problem with me owning this is, I am the sole developer for xUnit.net. Porting it is a large effort (especially including redesign of the output, to ensure that the test framework support is as flexible as necessary), to say nothing of ongoing maintenance work. This would be time taken away from the core of xUnit.net, and I'm not necessarily convinced that that's the best investment for xUnit.net's community.
spekt/testlogger#172 is almost near completion now. It just needs a review and a little bit more testing. So, once it's done, the junit report concern should not longer be valid.
Same story with test coverage and making test coverage work on GitLab and on Sonarqube, etc. Some projects can be done, and some cannot.
For coverage, ladeak are there specific blockers today?
Youssef Fahmy (@Youssef1313) thank you for the update, I think this was the major point missing. With coverage I see that cobertura format by Microsoft.Testing.Extensions.CodeCoverag is supported on GitLab today, and as I learned it will become supported on Sonarqube by end of the year (it is supported for other languages already).
Today the in my setup coverage collector with vstest collects both opencover and cobertura at the same time. I plan change and generate only cobertura and until cobertura is not supported by Sonarqube convert the format to a format that Sonarqube can parse.
A single MTP test project cannot use multiple test frameworks in all cases.
Having two test projects in a solution, where each test project uses a different test framework is supported. But you will need to keep in mind that different test frameworks may have different command-line options.
Having two test projects in a solution, where one is VSTest and the other is MTP is not supported today in all cases. They should work fine in IDE though, but you will face issues on command-line if you try to run dotnet test on such solution.
Activity
Youssef1313 commentedon Sep 1, 2025
This is interesting thing for us. Why cannot you migrate the whole solution at one go? What makes that hard?
ladeak commentedon Sep 1, 2025
Time and effort. This is a task someone can work through part by part, say over a few weeks period. Some of the tests use xunit, some mstest, they need to support different output formats, coverage formats etc.
For example, as I see JUnit.TestLogger is not yet supported, and some of the test projects need it (because of an integration with source control - in this case gitlab, which only handles junit). But other test projects that do not need junit.testlogger could be already migrated.
Same story with test coverage and making test coverage work on GitLab and on Sonarqube, etc. Some projects can be done, and some cannot.
Youssef1313 commentedon Sep 1, 2025
In the ideal scenario, you'd be able to add
<EnableMSTestRunner>true</EnableMSTestRunner>and<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>in Directory.Build.props, then all your MSTest and xUnit projects are MTP. The only remaining step will be to add<OutputType>Exe</OutputType>to all your test projects. But whether or not you can add OutputType in a centralized place depends very much on your exact scenario.For coverage, I think easiest is to align all your projects to use Microsoft.Testing.Extensions.CodeCoverage. Whether or not this is easy might depend on your specific case.
For JUnit logger, I think xUnit.net has built-in support for junit using
--report-junit, so you don't really need JUnit.TestLogger for xUnit projects. For MSTest projects, there is no built-in support for JUnit logging. This is tracked by #4268, or we could try to get JUnit.TestLogger to support MTP, finish #4268, or maybe xUnit.net could consider separating the junit support outside of xunit to be a generic MTP extension? cc Brad Wilson (@bradwilson)To answer specifically about mixing VSTest and MTP in the same solution, this is not a supported scenario for
dotnet test. However, if you are able to make two solution filters, one which is completely MTP and the other is completely VSTest, you can invokedotnet testtwice on each filter. However, keep in mind that with .NET 10 SDK, you will need to adjust dotnet.config before running eachdotnet testinvocation.For Visual Studio, this mixing MTP and VSTest works perfectly fine today AFAIK. But looping in Artur Spychaj (@drognanar) to confirm whether or not it's a supported scenario.
bradwilson commentedon Sep 2, 2025
I definitely believe somebody should own reporters in JUnit, NUnit, and CTRF format. That work could be based on the code that's in xUnit.net, but we obviously can't just replace our code with MTP extensions, since we also support running in non-MTP mode. What's also not clear to me is how much additional information would need to be made available beyond the basic model (much the same way that TRX requires test frameworks to implement additional data).
The problem with me owning this is, I am the sole developer for xUnit.net. Porting it is a large effort (especially including redesign of the output, to ensure that the test framework support is as flexible as necessary), to say nothing of ongoing maintenance work. This would be time taken away from the core of xUnit.net, and I'm not necessarily convinced that that's the best investment for xUnit.net's community.
Youssef1313 commentedon Sep 4, 2025
spekt/testlogger#172 is almost near completion now. It just needs a review and a little bit more testing. So, once it's done, the junit report concern should not longer be valid.
For coverage, ladeak are there specific blockers today?
ladeak commentedon Sep 4, 2025
Youssef Fahmy (@Youssef1313) thank you for the update, I think this was the major point missing. With coverage I see that cobertura format by
Microsoft.Testing.Extensions.CodeCoveragis supported on GitLab today, and as I learned it will become supported on Sonarqube by end of the year (it is supported for other languages already).Today the in my setup coverage collector with vstest collects both opencover and cobertura at the same time. I plan change and generate only cobertura and until cobertura is not supported by Sonarqube convert the format to a format that Sonarqube can parse.
Youssef1313 commentedon Sep 4, 2025
Maybe the third-party ReportGenerator could be of help here for you to convert cobertura to OpenCover?
Evangelink commentedon Sep 4, 2025
Definitely used that in the past.
ladeak commentedon Sep 4, 2025
Yes, that is the plan, thank you for the suggestion.
Youssef1313 commentedon Jan 14, 2026
Closing as answered. Mixed mode remains an unsupported scenario.
ladeak commentedon Jan 14, 2026
But it is actually supported within a solution where each project only uses one test framework, right?
Youssef1313 commentedon Jan 14, 2026