Guidance for running tests using MSTest v1 in Visual Studio 2017 15.8.1

14,527

Solution 1

I was getting a similar issue running Xamarin.UITests and resolved it by installing the "NUnit 2 Test Adapter" Extension in Visual Studio. In Visual Studio 2017 you do this from Tools > > Extensions and Updates... > Online > Search "NUnit Adapter" > click the NUnit 2 Test Adapter then the Download button to install. Restart Visual Studio when prompted to complete the installation.

Solution 2

It would be interesting to understand how the MSTest V1 framework assembly(Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll) is referenced in this project. The compatibility checkbox that also ended up being disabled in the image above should ensure that this project has MSTestV1 tests and enabled run tests. If it isn't then for some reason the detection logic is busted and needs to be fixed - a snippet on how the assembly is referenced would be helpful there.

As for moving to MSTest V2, this blog should help: https://blogs.msdn.microsoft.com/devops/2016/06/17/taking-the-mstest-framework-forward-with-mstest-v2/ . And for the specific issue you seem to be running into, this github issue on the repo sounds similar: https://github.com/Microsoft/testfx/issues/184 .

Solution 3

Caltor's answer pretty much solved it for me: it was the NUnit Adapter I needed. But I followed slightly different steps. Here they are for VS 2019 (but probably apply to VS 17 too):

  • Right clicked on the References node under my project in the solution explorer
  • Chose "Manager NuGet packages"
  • Clicked Browse
  • Searched for nunit3testadapter
  • Hit install on the result that popped up

The issue for me was similar to the OP's - the adapter was installed on some projects but not others. But confusingly this wasn't immediately visible under the "References" node for that project. The only node relating to nunit under that References node said "nunit.framework". So the references for test with and without the adapter looked the same.

Share:
14,527
SvenAelterman
Author by

SvenAelterman

Experienced IT professional and Microsoft-stack developer

Updated on June 22, 2022

Comments

  • SvenAelterman
    SvenAelterman almost 2 years

    I upgraded to Visual Studio 2017 last week. A solution with several test projects using MSTest v1 seemed to be fine at first. Most test projects execute tests fine. This is .NET Framework, not .NET Core.

    However, there is one project where I am encountering issues. It's an integration test project, meaning it runs web application tests using the ChromeDriver and Selenium. This project references NUnit, though that reference comes from another project reference. I am not actually using NUnit as my test framework.

    This is the error when trying to run any test in that particular test project: Could not find test executor with URI 'executor://mstestadapter/v1'. Make sure that the test executor is installed and supports .net runtime version . Test project {name} does not reference any .NET NuGet adapter. Test discovery or execution might not work for this project. It's recommended to reference NuGet test adapters in each test project in the solution.

    Disabling the option indicated below made everything work: Screen shot of Visual Studio 2017 Options, Test setting.

    I found this solution after browsing the preview release notes at https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-preview-relnotes#--visual-studio-2017-version-158-preview-4 (scroll down to "... What's New ..." and then .NET Test Adapter Extension). It mentions this breaking change (though it didn't break my other projects), but there is no mention of what to actually do to solve the problem.

    Of course, long-term, keeping that option unchecked doesn't seem feasible. So I am looking for guidance on how to proceed.

    I already tried to see if I could "quickly" upgrade to MSTest v2, but that had an issue because System.Runtime 4.1.2 couldn't be found. I tried adding System.Runtime 4.3.0 via NuGet, but that didn't solve the issue.

  • Manikandan Selvanathan
    Manikandan Selvanathan about 5 years
    To be more clear. Install NUnit Adapter 2 as a plugin. Tools-->Extenstions and Updates --> Search NUnit Adapter--> Install and Restart the visual studio.
  • Mash
    Mash almost 5 years
    In my case, I had to install the NUnit 3 Test Adapter but this led me in the right direction. Thanks!
  • velkoon
    velkoon about 4 years
    Pfft. I love programming. Thank you for the steps--This solved it for me :)
  • Colm Bhandal
    Colm Bhandal about 4 years
    You're welcome @velkoon. I, too, love programming, but I do not enjoy this tedious setup c**p!