C# 如何在 VS 2012 Professional RC 中添加假程序集?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11009332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 16:05:21  来源:igfitidea点击:

How do I add a fakes assembly in VS 2012 Professional RC?

c#tddvisual-studio-2012microsoft-fakes

提问by Dan Sorensen

According to the two articles below on VS 2012 and Microsoft Fakes Test Framework, I should be able to right click on an assembly in my test project's references and choose "Add Fakes Assembly" to create a new Microsoft Fakes Framework Assembly in Visual Studio 11 / 2012. However I do not find the context menu item in VS 2012 RC Professional where it should be. I may need to reference the Microsoft.QualityTools.Testing.Fakes assembly, but I cannot find it in the add reference search either. Has the required menu changed since beta? Do I need to install an extension?

根据下面关于 VS 2012 和 Microsoft Fakes Test Framework 的两篇文章,我应该能够在我的测试项目的引用中右键单击一个程序集,然后选择“添加 Fakes 程序集”以在 Visual Studio 11 中创建一个新的 Microsoft Fakes 框架程序集/ 2012。但是我没有在 VS 2012 RC Professional 中找到上下文菜单项。我可能需要引用 Microsoft.QualityTools.Testing.Fakes 程序集,但我也无法在添加引用搜索中找到它。自测试版以来,所需的菜单是否发生了变化?我需要安装扩展吗?

How do I add a fakes assembly in VS 2012 Professional RC?

如何在 VS 2012 Professional RC 中添加假程序集?

Articles referenced:

参考文章:

采纳答案by Chai

Update:VS2012 Update 2 will include Fakes support in Premium.

更新:VS2012 Update 2 将在 Premium 中包含 Fakes 支持。

See http://blogs.msdn.com/b/bharry/archive/2013/01/30/announcing-visual-studio-2012-update-2-vs2012-2.aspx

请参阅http://blogs.msdn.com/b/bharry/archive/2013/01/30/annoucing-visual-studio-2012-update-2-vs2012-2.aspx

I asked this question in the Microsoft Connect portal...and the answer is disappointing:

我在 Microsoft Connect 门户中问了这个问题……答案令人失望:

The RC documentation was incorrect. Fakes are available only in VS Ultimate. I have passed your concerns on the Fakes team. At the moment, we don't have any information about PEX for VS 2012.

RC 文档不正确。假货仅在 VS Ultimate 中可用。我已将您的担忧转嫁给 Fakes 团队。目前,我们没有关于 VS 2012 的 PEX 的任何信息。

My detailed question was:

我的详细问题是:

MSDN documentation states that the Fakes framework, the successor of Moles framework for isolatiion of code for unit tests is available in the Premium and Ultimate editions.

http://msdn.microsoft.com/en-us/library/dd264975(v=vs.110)

Also, elsewhere in MSDN blogs, Peter Provost confirmed the same some months ago for the VS2011 release:

http://blogs.msdn.com/b/visualstudioalm/archive/2012/03/09/10279666.aspx

But when I tried out the Premium RC today, I couldn't see the "Add Fakes Assembly" context menu option in my test project for my sample DLL containing code to test. It was only after I installed the Ultimate RC that I got the Fakes menu support.

This prompts me to ask of you to clarify the following:

1) Is my observation correct, that Fakes is indeed only available with Ultimate? Is that because of its dependency on IntelliTrace, which is an Ultimate-only feature?

2) If yes, then why is there conflicting information indicating the availability of Fakes with Premium?

3) Why should the Fakes framework be now dependent on IntelliTrace when it worked well without this dependency in VS 2010? This is essentially cutting off existing users of Moles with Professional or even Premium editions of VS 2010 and putting their upgrade to VS 2012 in question because of their existing reliance on Moles for their unit tests.

4) We are already using Moles with our VS 2010 Professional edition. So this observation indeed has me worried about the present decision to use Moles among our C# developers. At best, we can think of an upgrade to Premium for our large developer base (given that we also have code coverage support)... but an upgrade straight to Ultimate just to get UT support will never be on the cards.

I wish to have these points clarified at the earliest so that we can start looking for alternatives to Moles, in case your decision is indeed to keep Fakes exclusive to VS 2012 Ultimate.

MSDN 文档指出 Fakes 框架是用于单元测试代码隔离的 Moles 框架的继承者,可在 Premium 和 Ultimate 版本中使用。

http://msdn.microsoft.com/en-us/library/dd264975(v=vs.110)

此外,在 MSDN 博客的其他地方,Peter Provost 几个月前为 VS2011 版本确认了同样的内容:

http://blogs.msdn.com/b/visualstudioalm/archive/2012/03/09/10279666.aspx

但是,当我今天试用 Premium RC 时,在我的包含要测试的代码的示例 DLL 的测试项目中,我看不到“添加假冒程序集”上下文菜单选项。只有在我安装了 Ultimate RC 之后,我才获得了 Fakes 菜单支持。

这促使我要求您澄清以下几点:

1) 我的观察是否正确,Fakes 确实只有 Ultimate 可用?是因为它依赖于 IntelliTrace,这是一项仅限 Ultimate 的功能吗?

2) 如果是,那么为什么有相互矛盾的信息表明假货与 Premium 的可用性?

3) 当 Fakes 框架在 VS 2010 中没有这种依赖时运行良好,为什么现在应该依赖于 IntelliTrace?这实质上切断了使用 VS 2010 专业版甚至高级版的 Moles 的现有用户,并使他们升级到 VS 2012 成为问题,因为他们现有的单元测试依赖于 Moles。

4) 我们已经在 VS 2010 专业版中使用 Moles。所以这个观察确实让我担心我们的 C# 开发人员目前决定使用 Moles。充其量,我们可以考虑为我们庞大的开发人员群升级到 Premium(鉴于我们也有代码覆盖率支持)……但是为了获得 UT 支持而直接升级到 Ultimate 永远不会出现。

我希望尽早澄清这些要点,以便我们可以开始寻找 Moles 的替代品,以防您决定确实让 Fakes 成为 VS 2012 Ultimate 的专属。