将 NUnit 添加到 ASP.NET MVC 测试框架的选项
- 我已经安装了 nUnit。
- 我安装了VS2008团队版。
- 我安装了 ASP.Net MVC Preview 4 (Codeplex)。
在创建新的 MVC 项目时,如何让 Visual Studio 向我显示 nUnit 作为测试框架? 此时我仍然只有 Microsoft 测试框架作为选择。
更新:我安装了nUnit 2.5,但仍然没有成功。 根据我在谷歌上的搜索,我似乎需要为测试项目创建模板,以便它们显示在“创建单元测试项目”中。 我本以为 nUnit、xUnit、MBUnit 等都可以使用模板。 等人。 另外,看起来我需要创建注册表项。 有人有任何其他信息吗?
更新:我通过研究确定了这个问题的答案,并将其发布在下面。
- I have nUnit installed.
- I have VS2008 Team Edition installed.
- I have ASP.Net MVC Preview 4 (Codeplex) installed.
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
伙计,他们的发行说明中列出了 VS 2008 项目模板。 我想这并不意味着他们已经将其与对话框集成了。
我使用 MbUnit 和 Gallio 一切都很顺利。 我必须安装 Gallio 和 MbUnit 的 Alpha,当我阅读发行说明中的上述内容时,我认为他们也实现了它。
请密切关注 nUnit 网站以获取未来的 alpha 版本。 我相信他们很快就会实施。 您还可以自己实现该功能并提交补丁。 :-)
Man, they have VS 2008 project template listed in their release notes. I guess that doesn't mean they have it integrated with the dialog yet.
I use MbUnit with Gallio and everything worked like a charm. I had to install an Alpha of Gallio and MbUnit and when I read the above in the release notes, I figured they implemented it also.
Just keep a look out on nUnit's site for future alpha releases. I am sure they'll have it implemented soon. You could also implement the feature yourself and submit a patch. :-)
虽然他们没有与框架捆绑在一起,但这里有一个帖子链接,其中包含下载内容,可以自动为您创建“NUnit with moq”测试项目 NUnit with Moq
(在我的计算机上无法立即运行,W7 Beta,确保您使用提升的权限)
Although they do not have one bundled with the framework here is a link to post containing a download to automatically create the test project for "NUnit with moq" for you NUnit with Moq
(did not work right away on my computer, W7 Beta, make sure you use elevated permissions)
请安装 Testdriven.net 以将 NUnit 与 Visual Studio 集成。 MbUnit 和更高版本的 NUnit 还包含用于单元测试的项目模板。
您可以使用这些项目模板创建测试项目,然后引用您的 ASP.NET MVC 项目并能够测试其代码。
Do install Testdriven.net to integrate NUnit with Visual Studio. MbUnit and later versions of NUnit also contain project templates for unit tests.
You can use those project templates to create a test project and then reference to your ASP.NET MVC project and be able to test its code.
经过大量研究和实验,我找到了答案。
从较高的层面来看,您需要做的是:
测试框架的选择就这么多了! 不过,公平地说,MVC 还不是测试版。
毕竟,我确实在下拉框中显示了选择的框架(NUnit)。 然而,仍有一些不足之处:
因此,我可能还应该阅读此,其中讨论了为Visual Studio(在我上面链接的博客文章中也提到了。)不过我承认我很失望; 从所有关于 MVC 与其他测试框架配合良好等的讨论中,我认为注册第 3 方框架会更容易。
After a bunch of research and experimentation, I've found the answer.
From a high level, what you have to do is:
So much for the testing framework selection being easy! Although, to be fair MVC is not even beta yet.
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:
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.