MStest doesn't execute unit tests when OutputPath of the project changes

Igor M 6 Reputation points
2022-11-05T00:27:59.567+00:00

When I change the OutputPath for my unit test project the tests are still discoverable in Test Explorer, but when I try to run them (right-click -> Run) they don't run and I get the error below in Output window. Why it suddenly doesn't find that dll?

Building Test Projects  
Starting test discovery for requested test run  
========== Starting test discovery ==========  
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process exited with error: Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.TestPlatform.CoreUtilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.  
File name: 'Microsoft.TestPlatform.CoreUtilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'  
   at Microsoft.VisualStudio.TestPlatform.TestHost.Program.Main(String[] args)  
. Please check the diagnostic logs for more information.  
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(Boolean testHostExited)  
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)  
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)  
========== Test discovery aborted: 0 Tests found in 859.1 ms ==========  
========== Starting test run ==========  
========== Test run finished: 0 Tests (0 Passed, 0 Failed, 0 Skipped) run in < 1 ms ==========  

The bin folder in the new OutputPath location seems to have all files that would have been in the bin folder inside the project folder if I haven't changed the OutputPath.

I use MStest from Visual Studio 2022.

What am I missing here?

257338-mstest.png

Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
346 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 28,661 Reputation points Microsoft Vendor
    2022-11-07T08:31:27.047+00:00

    Hi @Igor M ,

    Welcome to Microsoft Q&A!

    Please try to rename (or delete) the hidden .vs, bin and obj folders in your project folder. Then run the tests again.

    If it doesn’t work, you can create a new test project and copy the code from the old test project.
    Please change the output path before running the tests.

    Sincerely,
    Anna
    *
    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.