Unit Testing Error - “Unable to get type” “Error:

2019-06-19 08:15发布

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?

3条回答
家丑人穷心不美
2楼-- · 2019-06-19 08:45

I fixed this for myself by cleaning the test project and then building it.

查看更多
萌系小妹纸
3楼-- · 2019-06-19 08:53

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.

查看更多
啃猪蹄的小仙女
4楼-- · 2019-06-19 09:08

It's also happens when library under test is in GAC. It's offen case when you develop for SharePoint.

Remove library from GAC if you don't need it there or deploy newest version to GAC.

查看更多
登录 后发表回答