简体   繁体   English

NUnit没有在Visual Studio 2010上工作?

[英]NUnit not working on Visual Studio 2010?

I'm new to NUnit and I just download it today and I can't get it working with visual studio. 我是NUnit的新手,今天我只是下载它,我无法使用Visual Studio。 (I'm new to Visual Studio as well) I'm following TekPub's Mastering C# 4.0 tutorial. (我也是Visual Studio的新手)我正在关注TekPub的Mastering C#4.0教程。

Screenshot: Something is missing within the red circle area. 屏幕截图:红色圆圈区域内缺少某些内容。 There should be some "green thing" on the side that let you double click on it and run the NUnit test. 应该有一些“绿色的东西”让你双击它并运行NUnit测试。
http://dl.dropbox.com/u/20422001/NunitMissing.jpg http://dl.dropbox.com/u/20422001/NunitMissing.jpg

As you can see on the above screenshot, the NUnit seems not working.... 正如您在上面的屏幕截图中看到的那样,NUnit似乎无法工作....

Did I miss something? 我错过了什么? Please advice. 请指教。 Thanks 谢谢

EDIT This is how it SHOULD look like. 编辑这就是它应该是什么样子。 I took a screenshot from the video tutorial: 我从视频教程中截取了截图:

http://dl.dropbox.com/u/20422001/nunit.jpg http://dl.dropbox.com/u/20422001/nunit.jpg

and here is the project files: 这是项目文件:

http://dl.dropbox.com/u/20422001/MasteringCSharp.rar http://dl.dropbox.com/u/20422001/MasteringCSharp.rar

As you can see, I don't have "Unit Test" Tab and "Unit Test Session"... 如您所见,我没有“单元测试”选项卡和“单元测试会话”......

You aren't doing anything wrong. 你没有做错任何事。 Out of the box, NUnit doesn't integrate directly with Visual Studio. 开箱即用,NUnit不直接与Visual Studio集成。 The screenshot from the video appears to be using Resharper's test runner. 视频的截图似乎是使用Resharper的测试运行器。

Typically testing with NUnit requires you to compile your test project and then load it into the NUnit GUI (nunit.exe) where the tests can be run from there. 通常使用NUnit进行测试需要您编译测试项目,然后将其加载到NUnit GUI(nunit.exe)中,在那里可以从那里运行测试。 When using the NUnit GUI, the project will reload anytime the assembly is recompiled. 使用NUnit GUI时,只要重新编译程序集,项目就会重新加载。 (I sometimes prefer having this in a separate process as it doesn't tie up Visual Studio's UI, but that's a matter of preference.) (我有时更喜欢在单独的过程中使用它,因为它不会占用Visual Studio的UI,但这是一个偏好问题。)

The added advantage of using a third party test runner like Resharper, TestDriven.net, Galileo, etc is that it allows you to run or debug the tests directly from within the IDE. 使用像Resharper,TestDriven.net,Galileo等第三方测试运行器的额外优势是它允许您直接从IDE中运行或调试测试。 You can accomplish the same thing using NUnit by configuring Visual Studio to attach to NUnit and debug your tests from the external process. 您可以通过将Visual Studio配置为附加到NUnit并从外部进程调试测试来使用NUnit完成相同的操作。 This post shows you how . 这篇文章告诉你如何

I haven't seen that particular video, but it sounds like you need an NUnit test runner for Visual Studio. 我没有看到那个特定的视频,但听起来你需要一个适用于Visual Studio的NUnit测试运行器。

Check out the following: 请查看以下内容:

Visual NUnit 2010 - free! Visual NUnit 2010 - 免费!

TestDriven.net TestDriven.net

ReSharper ReSharper的

That my friend is JetBrains' Resharper - it's a paid add-in to Visual Studio that allows you to run tests from within the IDE. 我的朋友是JetBrains的Resharper - 它是Visual Studio的付费插件,允许您在IDE中运行测试。 Highly recommended if you're working for a prolonged period in VS. 如果你在VS工作了很长时间,强烈推荐。

Of course since you're just starting out, you could use the NUnit GUI to run your tests. 当然,因为刚刚开始,您可以使用NUnit GUI来运行测试。 You can also set it to run tests after each build. 您还可以将其设置为在每次构建后运行测试。 Tools > Settings > Test Loader > Assembly Reload. Check "Re-Run last tests run". Apply changes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM