[英]How to debug unit tests that use Microsoft Moles framework
Our team is working on writing unit tests for a .Net project. 我们的团队正在为.Net项目编写单元测试。 We use “Visual Studio 2010” IDE, “NUnit” (v. 2.5.9) unit-testing framework, and “Microsoft Moles” type-isolating framework.
我们使用“Visual Studio 2010”IDE,“NUnit”(v.2.5.9)单元测试框架和“Microsoft Moles”类型隔离框架。
We have encountered a problem: we couldn't debug unit tests that use Moles (while tests that don't use it are debugged with no problems). 我们遇到了一个问题:我们无法调试使用Moles的单元测试(而不使用它的测试没有问题)。 Tests that use Moles are failed with the following error message:
使用Moles的测试失败,并显示以下错误消息:
Microsoft.Moles.Framework.Moles.MoleInvalidOperationException : Moles requires tests to be IN an instrumented process.
Microsoft.Moles.Framework.Moles.MoleInvalidOperationException:Moles要求测试在检测过程中。
Does anyone have ideas why debugging of those tests not working? 有没有人有想法为什么那些测试的调试不起作用?
Thanks in advance! 提前致谢!
From the Moles Manual: 来自Moles手册:
Assembly 部件
Microsoft.Moles.NUnit.dll You will have to register that add-in with NUnit by copying the Microsoft.Moles.NUnit.dll assembly in the NUnit bin/addins folder. Microsoft.Moles.NUnit.dll您必须通过复制NUnit bin / addins文件夹中的Microsoft.Moles.NUnit.dll程序集来向NUnit注册该加载项。
NUnit Version NUnit版本
2.5.2.9222 (for other NUnit versions, recompile the attribute from sources) 2.5.2.9222(对于其他NUnit版本,从源代码重新编译属性)
Example Usage 示例用法
using NUnit.Framework;
using Microsoft.Moles.Framework.NUnit;
[TestFixture]
public class NUnitTest
{
[Test]
[Moled] // set up of the mole context around the test case
public void TestWithMoles() {
...
}
// alternative not using [Moled]
[Test]
public void TestWithMoles() {
using(MolesContext()) { // clears moles leaving context
...
}
}
}
Command Line 命令行
Make sure you use the /domain=None argument when invoking the NUnit console runner. 确保在调用NUnit控制台运行程序时使用/ domain = None参数。
moles.runner.exe /r:nunit-console.exe /args=”/domain=None” ..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.