C# .NET 4.0 测试框架?

发布于 2024-09-26 11:22:41 字数 563 浏览 0 评论 0原文

如果我没记错的话,NUnit 是单元测试事实上的标准,但我刚刚下载了它,编写了一个简单的测试,然后显然我必须启动 GUI 并加载我的 .exe< /code> 程序集,它根本就失败了。

我尝试

C:\Program Files (x86)\NUnit 2.5.7\bin\net-2.0\nunit.exe.config

按照在此问题中的建议进行编辑,但这并没有要么工作,所以我尝试下载nunit源代码并在vs2010中编译它,但它甚至无法编译。说找不到punit.framework.dll该解决方案说“不包含 AllTestsExecuted 的定义”,所以我在这里有点沮丧。您可能认为 .net 4 会有一个易于使用和运行的框架,不是吗?

所以我的问题是,如何让 NUnit 工作,或者是否有另一个框架可以减轻我的痛苦?

If I'm not mistaken, NUnit is the de-facto standard for unit testing, but I've just downloaded it, wrote a simple test, and then apparently I have to fire up the GUI and load my .exe assembly, which simply failed.

I tried editing

C:\Program Files (x86)\NUnit 2.5.7\bin\net-2.0\nunit.exe.config

As suggested in this question, but that didn't work either, so I tried downloading the nunit source code and compiling it in vs2010, but it doesn't even compile. Says punit.framework.dll could not be found. That solution says "does not contain a definition for AllTestsExecuted", so I'm getting a little frustrated here. You'd think there would be an easy-to-use-and-get-running framework for .net 4, no?

So my question is, how do I either get NUnit working, or is there another framework that will cause me less agony?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

清秋悲枫 2024-10-03 11:22:41

您不必使用 NUnit GUI 来运行测试。您可以在 Visual Studio 中使用 TestDriven.NET。另外,如果您碰巧使用 Resharper,它有一个单元测试运行器,也可以与 NUnit 一起使用。

You don't have to use the NUnit GUI to run your tests. You can use TestDriven.NET from within Visual Studio. Also, if you happen to be using Resharper, that has a unit test runner which works with NUnit also.

久光 2024-10-03 11:22:41

如果您没有做任何异常的事情,我建议 微软的单元测试框架。我发现 VS 集成太容易了,甚至不用担心 NUnit。我同意 NUnit 似乎是事实上的标准,但如果您正在寻找快速而简单的东西。恕我直言,对于典型的 Visual Studio 程序员来说,Microsoft 的方法是最简单的。

If you're not doing anything out of the ordinary, I recommend Microsoft's Unit Testing Framework. I find it's VS integration too easy to even worry about NUnit. I agree NUnit seems to be the defacto standard, but if you're looking for something quick and easy. Microsoft's way is the easiest for a typical Visual Studio programmer IMHO.

苍风燃霜 2024-10-03 11:22:41

我不是 C# 程序员(幸运的是;-)),但我听说过有关 xUnit 的好消息。测试几乎可以按照您想要的方式运行(命令行、GUI、Visual Studio 集成等),而且看起来使用起来相当简单。

I am not a C# programmer (fortunately ;-) ) but I've heard good things about xUnit. Tests can be run pretty much however you want (command line, GUI, Visual Studio integration, and more) and it looks reasonable simple to use.

π浅易 2024-10-03 11:22:41

对于 NUnit 的 GUI 测试运行程序,请确保您选择了正确的框架版本。它位于“文件”菜单中。如果您的测试或任何依赖项是 32 位,请确保您运行的是 32 位版本的测试运行程序。

Testdriven.net 是一个更好的测试运行器,但我有时也喜欢使用 NUnit 的 GUI 运行器。

For NUnit's GUI test runner, make sure you've selected the right framework version. Its in the "File" menu. If your test or any dependencies are 32-bit be sure you're running the 32bit version of the test runner.

Testdriven.net is a better test runner, but I like using NUnit's GUI runner too at times.

兔姬 2024-10-03 11:22:41

NUnit 实际上使用起来非常简单,所以我想说,更有可能的是你在某个地方犯了错误,而不是软件。

请务必遵循本指南

  • 确保 [TestFixture] 和 [Test] 属性位于正确的位置以及引用的所有相关程序集。
  • 确保您在 NUnit GUI 中加载正确的 dll。

如果问题出在 GUI 上,您可以使用 Resharper 的单元测试功能来代替。

NUnit is infact very simple to use, so I would say that it's more likely that you are making a mistake somewhere, not the software.

Make sure you follow this guide.

  • Ensure that you have the [TestFixture] and [Test] attributes in the correct places and all the relevant assemblies referenced.
  • Make sure that you are loading the correct dll in the NUnit GUI.

If its the GUI that is the issue, you can use Resharper's unit testing feature in stead.

凌乱心跳 2024-10-03 11:22:41

如果您使用 Visual Studio 2010,则可以使用 MSTest。只需单击 CTRL + ALT + R,它将运行您的测试并在 Visual Studio 本身中显示结果。

如果我没记错的话,同一个测试运行器也适用于 NUnit。

If you use Visual Studio 2010, you can use MSTest. Just click CTRL + ALT + R and it will run your tests and show the results in Visual Studio itself.

That same test-runner will also work for NUnit, if I am not mistaken.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文