NUnit的添加为ASP.NET MVC测试框架的选项 [英] Adding NUnit to the options for ASP.NET MVC test framework

查看:118
本文介绍了NUnit的添加为ASP.NET MVC测试框架的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 我安装NUnit的。

  • 我安装了VS2008团队版。

  • 我有ASP.Net MVC preVIEW 4(codePLEX)安装。

如何让Visual Studio中创建一个新的MVC项目时告诉我NUnit的一个测试框架?此时我仍然只有微软测试框架作为一种选择。

How do I make Visual Studio show me nUnit as a testing framework when creating a new MVC project? At this point I still only have the Microsoft Testing Framework as a choice.

更新:我安装NUnit的2.5,但仍然没有成功。从我发现谷歌搜索,似乎我需要的为了创建的用于测试项目的模板,让他们在创建单元测试项目显示。我本来以为模板可供随时NUnit的,的xUnit,MbUnit的,等。人。此外,它看起来像我需要创建注册表项。任何人有任何更多的信息?

Update: I installed nUnit 2.5, but still with no success. From what I've found Googling, it would seem I need to create templates for the test projects in order for them to be displayed in the "Create Unit Test Project". I would have thought that templates be readily available for nUnit, xUnit, MBUnit, et. al. Also, it looks like I need to created registry entries. Anybody have any additional information?

更新:我决定通过研究这个问题的答案,它的贴在下面。

Update: I determined the answer to this through research and it's posted below.

推荐答案

一帮研究和实验后,我找到了答案。

After a bunch of research and experimentation, I've found the answer.


  • 对于记录,NUnit的当前版本2.5的Alpha的的似乎包含在Visual Studio 2008测试项目模板

  • 我跟着指示这里其中介绍了如何创建自己的项目模板,然后添加,让您的模板出现在下拉框中相应的注册表项中的创建单元测试项目的一个MVC项目的对话框。

  • For the record, the current release of nUnit 2.5 Alpha does not seem to contain templates for test projects in Visual Studio 2008.
  • I followed the directions here which describe how to create your own project templates and then add appropriate registry entries that allow your templates to appear in the drop-down box in the Create Unit Test Project dialog box of an MVC project.

从一个高的水平,你必须做的是:

From a high level, what you have to do is:


  1. 创建一个项目

  2. 导出为模板(这会导致一个ZIP压缩包)

  3. 从本地用户的模板文件夹复制到Visual Studio主模板测试文件夹

  4. 执行 devenv.exe的/设置

  5. 运行注册表编辑器并创建一些注册表项。

  1. Create a project
  2. Export it as a template (which results in a single ZIP archive)
  3. Copy it from the local user's template folder to the Visual Studio main template test folder
  4. Execute devenv.exe /setup
  5. Run regedit and create a few registry entries.

这么多的测试框架的选择是容易!虽然是公平的MVC甚至不是公测呢。

So much for the testing framework selection being easy! Although, to be fair MVC is not even beta yet.

在所有这一切,我没有得到的选择(NUnit的)框架在下拉框中显示出来。但是,仍然有一点有待改进:

After all that, I did get the framework of choice (NUnit) to show up in the drop down box. However, there was still a bit left to be desired:


  • 虽然测试项目才能正确创建的,它没有自动有一个项目引用到主MVC项目。当使用的 Visual Studio的单元测试的作为测试项目,它会自动执行此操作。

  • 我试图打开生成的ZIP文件并编辑MyTemplate.vssettings为了纠正上述问题以及调整的事物的名称文件以及该项目的.csproj文件,所以他们会显得更人性化。这出于某种原因不能正常工作。生成的ZIP文件无法通过WinZip或赢-RARα更新 - 每一个表示存档已损坏。每个人都可以提取的内容,虽然。于是,我试着更新提取的文件,然后重新创建ZIP文件。 Visual Studio中不喜欢它。

  • Although the test project gets properly created, it did not automatically have a project reference to the main MVC project. When using Visual Studio Unit Test as the test project, it automatically does this.
  • I tried to open the ZIP file produced and edit the MyTemplate.vssettings file as well as the .csproj project file in order to correct the aforementioned issue as well as tweak the names of things so they'd appear more user friendly. This for some reason does not work. The ZIP file produced can not be updated via WinZip or Win-Rar -- each indicates the archive is corrupt. Each can extract the contents, though. So, I tried updating the extracted files and then recreating the ZIP file. Visual Studio did not like it.

所以,我也许应该阅读与其中讨论了为Visual Studio制作项目模板(在博客文章中,我联系到上文所引用),我承认自己虽然感到失望;从所有人都在谈论MVC与其他测试框架打得不好,等等,我认为它会更容易注册一个第三方的框架。

So, I should probably read this as well which discusses making project templates for Visual Studio (also referenced in the blog post I linked to above.) I admit to being disappointed though; from all the talk about MVC playing well with other testing frameworks, etc, I thought that it'd be easier to register a 3rd party framework.

这篇关于NUnit的添加为ASP.NET MVC测试框架的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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