关键是“痣”。找不到
我为我的解决方案创建了一个单元测试项目,并使用 Moles 绕道所有数据读取。 今天,当我启动所有测试时,最终结果是这样的错误:“无法加载主机类型“Moles”:找不到密钥“Moles”。”对于包含属性 HostType("Moles") 的每个测试。
我不明白问题的原因,因为我从三个月前开始使用 Moles,但从未遇到过此类问题。
谢谢!!!
I create a unit-test project for my solution and I'm using Moles to detour all data reading.
When today I launch all tests, at end the result was an error like this "the hosttype "Moles" cannot be loaded: The key 'Moles' cannot be found." for every test that contains the attribute HostType("Moles").
I don't understand the reason of problem because I'm using Moles from three months ago and I never have had this kind of problem.
Thanks!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个非常古老的问题,提问者现在可能已经找到了解决方案,但由于这是 Google 中此错误的第一个结果之一,所以这是我发现的:
我(和许多其他人,似乎)遇到了这个运行依赖于 Moles 的 64 位测试时出现问题。
首先,确保您安装了正确的“位数”的摩尔。 Moles 框架有 x86 和 x64 版本。根据我的经验,安装在 64 位计算机上的 32 位框架实际上看起来一切正常,但您的测试将无法运行。您可以在此处安装 64 位框架:
Moles 64 位框架
我建议在安装之前关闭 VS 2010,但我不知道这是否有什么区别。
接下来,以某种方式确保您的 Moles 托管测试使用 64 位(如果需要)。为了实现这一点,我将测试主机保留为“默认”,但在测试项目的 AssemblyInfo.cs 文件中设置以下内容:
然后,仅对于我想在 Moles 中运行的测试,我将此属性添加到测试方法中
:这,一切都对我有用。
This is a very old question, and the asker has likely found a solution by now, but as this is one of the first results for this error in Google, here is what I have found:
I (and many others, seemingly) encountered this issue when running 64-bit tests that depend on Moles.
First, make sure you have the correct "bitness" of moles installed. There are x86 and x64 versions of the moles framework. It was my experience that the 32-bit framework installed on a 64-bit machine will actually look like everything is working properly, but your tests will not run. You can install the 64-bit framework here:
Moles 64 bit Framework
I recommend closing VS 2010 before you install, but I don't know if it makes any difference.
Next, make sure, one way or another, that your Moles-hosted tests are using 64 bit if they need to. To achieve this, I left my testing host as "Default", but set the following in my test project's AssemblyInfo.cs file:
Then, only for the tests I wanted to run in Moles, I added this attribute to the test method:
After this, everything worked for me.