单元测试错误-“无法获取类型" “错误:无法加载类型" “来自组装" [英] Unit Testing Error - "Unable to get type" "Error: Could not load type" "from assembly"

查看:102
本文介绍了单元测试错误-“无法获取类型" “错误:无法加载类型" “来自组装"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的新单元测试出现此错误:

I am getting this error with my new unit test:

无法获取MyTestProject.MyTestClass,MyTestProject类型.错误:无法从程序集"MyTestProject"中加载类型"MyTestProject.MyTestClass"..

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.

如果我在Resharper中运行测试(而不是在Visual Studio Test运行器中内置),则工作正常. (我只会用它,但是速度较慢.)

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.)

知道这意味着什么吗?

推荐答案

在我看来,Visual Studio单元测试运行器在单元测试的命名上有些落后.重命名名称空间或类时,有时会发生这种情况.

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.

为我工作.

这篇关于单元测试错误-“无法获取类型" “错误:无法加载类型" “来自组装"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆