Search code examples
visual-studiounit-testingmstest

Unit Testing Error - "Unable to get type" "Error: Could not load type" "from assembly"


I am getting this error with my new unit test:

Unable to get type MyTestProject.MyTestClass, MyTestProject. Error: Could not load type 'MyTestProject.MyTestClass' from assembly 'MyTestProject'..

I have other tests in the project that were working just fine and now they are all showing a similar error message.

If I run the test in Resharper (rather than the built in Visual Studio Test runner) then it works fine. (I would just use that, but it is slower.)

Any idea what this could mean?


Solution

  • It seems to me that the Visual Studio unit test runner is a little bit behind on the naming of your unittests. This sometimes happens when you rename a namespace or class.

    This should clear the interenal cache: unload the project from your solution, run all tests, than reload the project.

    Worked for me.