试图将Moles与NUnit一起使用.得到“痣要求测试是一种仪器化的过程". [英] Trying to use Moles with NUnit. Getting "Moles requires tests to be an instrumented process"

查看:175
本文介绍了试图将Moles与NUnit一起使用.得到“痣要求测试是一种仪器化的过程".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将痣与NUnit一起使用,并收到以下错误痣需要将测试作为检测过程".我也在Visual Studio 2008中使用Visual NUnit来使此工作正常进行.欢迎任何帮助.

I am trying to use moles with NUnit and am getting the following error "Moles requires tests to be an instrumented process". I am also using Visual NUnit within Visual Studio 2008 to get this working. Any help is welcome.

推荐答案

这是我为了使Moles与NUnit一起工作而做的:

This is what I did in order to make Moles work with NUnit:

  1. C:\Program Files (x86)\Microsoft Moles\Documentation\moles.samples.zip处获取存档,并提取Moles解决方案文件夹.

  1. Grab the archive at C:\Program Files (x86)\Microsoft Moles\Documentation\moles.samples.zip and extract the Moles solution folder.

在Visual Studio(2008)中为发行版构建NUnit项目.

Build the NUnit project in Visual Studio (2008) for Release.

将输出文件Microsoft.Moles.NUnit.dllMicrosoft.Moles.NUnit.xml...\Moles\NUnit\bin\Release\复制到C:\Program Files (x86)\NUnit 2.5.9\bin\net-2.0\addins\.我怀疑这是重新编译NUnit插件的步骤,而不是使用来自下载和下载的插件.安装是实际的解决方法.

Copy the output files Microsoft.Moles.NUnit.dll and Microsoft.Moles.NUnit.xml from ...\Moles\NUnit\bin\Release\ to C:\Program Files (x86)\NUnit 2.5.9\bin\net-2.0\addins\. I suspect that this step of re-compiling the NUnit addin instead of using the one coming from the download & install was the actual solving point.

在VS测试项目中,确保添加对刚刚复制的C:\Program Files (x86)\NUnit 2.5.9\bin\net-2.0\addins\Microsoft.Moles.NUnit.dll的引用.

In your VS test project, make sure you add a reference to the C:\Program Files (x86)\NUnit 2.5.9\bin\net-2.0\addins\Microsoft.Moles.NUnit.dll you just copied.

在VS测试类中,用[Moled]属性标记一个测试方法(这将需要一个using Microsoft.Moles.Framework.NUnit).或者,将其实现包装在using (MolesContext.Create()) { ... }块中(这需要一个using Microsoft.Moles.Framework).

In your VS test class, mark a test method with the [Moled] attribute (this will require an using Microsoft.Moles.Framework.NUnit). As an alternative, wrap its implementation within an using (MolesContext.Create()) { ... } block (this will require an using Microsoft.Moles.Framework).

在命令行中,使用以下命令通过痣赛跑者调用NUnit测试赛跑者:"C:\Program Files (x86)\Microsoft Moles\bin\moles.runner.exe" "path\to\your\test\assembly.dll" /r:"C:\Program Files (x86)\NUnit 2.5.9\bin\net-2.0\nunit-console.exe" /x86 /args:"/domain=None"

From the command line, invoke NUnit test runner through the moles runner with the following: "C:\Program Files (x86)\Microsoft Moles\bin\moles.runner.exe" "path\to\your\test\assembly.dll" /r:"C:\Program Files (x86)\NUnit 2.5.9\bin\net-2.0\nunit-console.exe" /x86 /args:"/domain=None"

我发现[Moled]属性不能与[TestCase(...)]一起使用,它使您回到了非仪器化的错误情况.相反,在这种情况下,using (MolesContext.Create())块也可以工作.

I found that [Moled] attribute does not work with [TestCase(...)] and it brings you back to the uninstrumented error scenario. Instead the using (MolesContext.Create()) block works in that case too.

一旦发现一切正常,就可以考虑将痣运行器作为Visual Studio中的外部工具运行.遵循使用Visual Studio中的NUnit Console运行Moles 中的说明,如步骤6中所述更新参数.

Once you find that everything works, you might consider running moles runner as an external tool within Visual Studio. Follows instructions in Running Moles using NUnit Console from Visual Studio, updating the arguments as in step 6.

请注意,这是在装有NUnit 2.5.9,Microsoft Pex和Moles(x86)0.94.51006.1的Windows 7 64位计算机上.考虑不同路径,版本等的实际文件夹.

Please note that this was on a Windows 7 64bit machine, with NUnit 2.5.9, Microsoft Pex and Moles (x86) 0.94.51006.1. Consider your actual folders for different paths, versions, etc.

这篇关于试图将Moles与NUnit一起使用.得到“痣要求测试是一种仪器化的过程".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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