Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSTest cannot find TestAdapter.dll

I'm using the built-in Visual Studio test tools (Test -> Run -> etc in the menu). I just started having a problem where I get the following error when I try to run tests

[3/29/2018 1:39:14 PM Error] System.IO.FileNotFoundException: C:\Users\brubin\AppData\Local\Temp\VisualStudioTestExplorerExtensions\MSTest.TestAdapter.1.1.18/build/_common/Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.PerformShadowCopy(IEnumerable'1 testExtensions)

That's followed by some errors that say

Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

When I look at the folder C:\Users\brubin\AppData\Local\Temp\VisualStudioTestExplorerExtensions\MSTest.TestAdapter.1.1.18/build/_common/, there are no files in that folder. However, I haven't knowingly changed anything about my test setup and this was working several days ago, so I don't know why it would have stopped working.

My projects are using the MSTest.TestFramework (MSTest V2) version v1.2 NuGet package.

One thing I noticed that may have caused this problem is that if I go to Tools -> Extensions and Updates, I see that my Microsoft Visual Studio Test Platform was updated a few days ago, on 3/23 (I think that's when I installed a Visual Studio update). However, if that broke something, I have no idea where to look to see what's broken, or how to fix it.

enter image description here

like image 446
Ben Rubin Avatar asked Mar 29 '18 17:03

Ben Rubin


4 Answers

For me, clearing the VisualStudioTestExplorerExtensions folder and restarting Visual Studio (as per this github issue) did the trick. In my case, it contained two folders for different versions of MSTest.TestAdapter, I don't know whether or not that's relevant.

like image 151
Tim Avatar answered Nov 03 '22 19:11

Tim


For anyone else who stumbles on this question, the problem was caused because a few of my test projects didn't have the MSTest.TestAdapter NuGet package included. I added the MSTest.TestAdapter package to all of my test projects, and the problem seems to be solved permanently now.

like image 23
Ben Rubin Avatar answered Nov 03 '22 18:11

Ben Rubin


I spent the whole last week trying to solve the same issue. Only yesterday did I realize that running tests from the console is a time saver. Much to my surprise, I've just moved all my project -which was inside a "OneDrive" folder, to a different location. Now, it works like a charm! All my tests run from the Visual Studio IDE. I don't know if moving the files had anything to do with it, but you can give it a try.

like image 2
Fabian Avatar answered Nov 03 '22 19:11

Fabian


Reinstalling all solution's Nuget packages fixed this issue for me.

Please run this command on the package console:

Update-Package -reinstall

then try again, or restart VS, then try again.

Reference: https://ardalis.com/force-nuget-to-reinstall-packages-without-updating/

like image 1
Amine Boulaajaj Avatar answered Nov 03 '22 19:11

Amine Boulaajaj