Skip to content

.NET Workaround for mixing MTP and vstest projects in a solution #6484

Closed

Description

@ladeak

Summary

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?

Ref: https://learn.microsoft.com/de-de/dotnet/core/testing/microsoft-testing-platform-integration-dotnet-test

Background and Motivation

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?

Activity

  1. Youssef1313 commented on Sep 1, 2025

    @Youssef1313
    Member

    I would like to introduce MTP and gradually migrate to it, but I can only do it project by project due to the scale.

    This is interesting thing for us. Why cannot you migrate the whole solution at one go? What makes that hard?

  2. added
    area/mtp
    external/dotnet-test
    and removed
    needs/triage
    on Sep 1, 2025
  3. ladeak commented on Sep 1, 2025

    @ladeak
    Author

    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.

  4. Youssef1313 commented on Sep 1, 2025

    @Youssef1313
    Member

    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.

  5. bradwilson commented on Sep 2, 2025

    @bradwilson

    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.

  6. Youssef1313 commented on Sep 4, 2025

    @Youssef1313
    Member

    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?

  7. ladeak commented on Sep 4, 2025

    @ladeak
    Author

    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.

  8. added
    needs/attention
    and removed
    needs/author-feedback
    on Sep 4, 2025
  9. Youssef1313 commented on Sep 4, 2025

    @Youssef1313
    Member

    Maybe the third-party ReportGenerator could be of help here for you to convert cobertura to OpenCover?

  10. Evangelink commented on Sep 4, 2025

    @Evangelink
    Member

    Definitely used that in the past.

  11. ladeak commented on Sep 4, 2025

    @ladeak
    Author

    Yes, that is the plan, thank you for the suggestion.

  12. Youssef1313 commented on Jan 14, 2026

    @Youssef1313
    Member

    Closing as answered. Mixed mode remains an unsupported scenario.

  13. added
    type/question
    and removed
    needs/attention
    on Jan 14, 2026
  14. ladeak commented on Jan 14, 2026

    @ladeak
    Author

    But it is actually supported within a solution where each project only uses one test framework, right?

  15. Youssef1313 commented on Jan 14, 2026

    @Youssef1313
    Member
    • 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mtpexternal/dotnet-testtype/question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions