简体   繁体   English

NUnit 与 .NET 4.0 而不是 .NET-1.1 / .NET-2.0。 我需要的 DLL 在哪里?

[英]NUnit with .NET 4.0 rather than .NET-1.1 / .NET-2.0. Where is the DLL I need?

I've been reading and trying to use NUnit, and so far the books/articles I am reading say that in the bin folder of NUnit, there should be nunit.framework.dll , which I need to reference in my project.我一直在阅读并尝试使用 NUnit,到目前为止,我正在阅读的书籍/文章说,在 NUnit 的 bin 文件夹中,应该有nunit.framework.dll ,我需要在我的项目中引用它。

But the strange thing is that there is no nunit.framework.dll , but there are two folders: net-1.1 and net-2.0.但奇怪的是,并没有nunit.framework.dll ,而是有两个文件夹:net-1.1 和 net-2.0。

I use neither, I am working in VS 2010 with .NET 4.0.我都不使用,我在 VS 2010 中使用 .NET 4.0。

Is NUnit deprecated? NUnit 是否已弃用?

Why would they only have two folders for old versions of .NET?为什么他们只有两个旧版本的 .NET 文件夹?

To start off, NUnit is in no way deprecated and has become de facto primary unit testing framework for .NET.首先,NUnit 绝不会被弃用,它实际上已成为 .NET 的主要单元测试框架。

However, as a testing framework, it doesn't involve compiling expressions, doesn't use LINQ or dynamic language constructs, and in its current implementation relies on feature found even in .NET 1.0, such as attributes .但是,作为一个测试框架,它不涉及编译表达式,不使用 LINQ 或动态语言结构,并且在其当前实现中依赖于甚至在 .NET 1.0 中发现的特性,例如属性

However, with the release of .NET 2.0, a new CLR was shipped.然而,随着 .NET 2.0 的发布,一个新的 CLR 被交付。 Old .NET 1.1 assemblies had to be “remapped” in the application configuration file in order to be picked up by the new CLR, and people would get issues with running their .NET 2.0 applications with a library compiled for .NET 1.1.旧的 .NET 1.1 程序集必须在应用程序配置文件中“重新映射”才能被新的 CLR 拾取,并且人们会在运行 .NET 2.0 应用程序时遇到问题,使用为 Z303CB0EF9EDB9082D611BBBE558 编译的库。

When .NET 3.0 and .NET 3.5 came out, they didn't carry a new CLR along.当 .NET 3.0 和 .NET 3.5 出来时,他们并没有携带新的 CLR。 Both of them still use .NET 2.0 CLR and only add some libraries (WPF, WCF) and language features (such as LINQ) with them.它们都仍然使用 .NET 2.0 CLR,并且只添加了一些库(WPF、WCF)和语言特性(例如 LINQ)。 Because these releases don't bring changes to CLR, there is absolutely no sense in distributing separate library versions for them, as the binaries would stay exactly the same, referencing version of mscorlib found in .NET 2.0.因为这些版本不会对 CLR 进行更改,所以为它们分发单独的库版本绝对没有意义,因为二进制文件将保持完全相同,引用 .NET 2.0 中的mscorlib版本。

I'm not sure about .NET 4.0 and if it requires entry in App.config to properly load .NET 2.0-compiled NUnit library so I am open to comments on this.我不确定 .NET 4.0 是否需要进入App.config才能正确加载 .NET 2.0 编译的 NUnit 库,所以我愿意对此发表评论。

There's a quote from NUnit blog explaining separate 1.1 and 2.0 packaging: NUnit 博客中有一段引述解释了单独的 1.1 和 2.0 打包:

So, if it's possible to run the original, built-with-net-1.1 version of NUnit under any version of the CLR, why do we need a separate.Net 2.0 version?那么,如果可以在任何版本的 CLR 下运行原始的 built-with-net-1.1 版本的 NUnit,为什么我们需要单独的 .Net 2.0 版本? Strictly speaking, we don't.严格来说,我们没有。 But it's convenient for a few reasons:但它很方便有几个原因:

  1. Folks seem to have an inordinate amount of trouble getting NUnit to run under the proper framework version.人们似乎很难让 NUnit 在正确的框架版本下运行。 Having a special version will make their lives a bit easier, not to mention mine, since I have to answer all the questions.拥有一个特殊版本会让他们的生活更轻松,更不用说我的了,因为我必须回答所有问题。

  2. Eventually, we will need a separate version.最终,我们将需要一个单独的版本。 It's inevitable that people will begin to use 2.0-only features in their tests.人们不可避免地会在他们的测试中开始使用仅 2.0 的功能。 Imagine an Assert on a nullable value.想象一个可空值的断言。 Or a generic TestFixture class.或通用 TestFixture class。 We'll be able to deal with some of those things from an NUnit built with.Net 1.1, but many of them will either require.Net 2.0 or be much simpler to implement with.Net 2.0.我们将能够通过使用 .Net 1.1 构建的 NUnit 处理其中的一些事情,但其中许多需要.Net 2.0 或者使用.Net 2.0 实现起来要简单得多。

For now, the.Net 2.0 builds are identical in features to the.Net 1.1 builds.目前,.Net 2.0 版本在功能上与 .Net 1.1 版本相同。 We have reflected this in not changing the version numbering for now.我们已经反映了这一点,暂时不更改版本编号。 Those using one or the other framework version exclusively can download a copy of NUnit built to use that version without missing out on any features.那些只使用一个或另一个框架版本的人可以下载为使用该版本而构建的 NUnit 副本,而不会错过任何功能。 Those using both versions have the choice of installing both versions side by side – just be careful which one you reference – or using the command-line /framework option to select the correct version on the fly.使用这两个版本的用户可以选择并排安装这两个版本 - 请注意您引用的版本 - 或者使用命令行 /framework 选项来 select 即时安装正确的版本。

(highlighting is mine) (突出显示是我的)

However, it was posted a long time ago (November 2006) so probably by now the versions do differ.但是,它是很久以前(2006 年 11 月)发布的,所以现在版本可能有所不同。

Goto http://nuget.org/ and install NuGet.转到http://nuget.org/并安装 NuGet。 Then follow the instructions on how to add a NuGet package to your project.然后按照有关如何将 NuGet package 添加到您的项目的说明进行操作。 Then search for NUnit and it will automatically import the correct dll for your project.然后搜索 NUnit,它会自动为您的项目导入正确的 dll。

By the way, with a .NET 4.0, you can use any dll above 2.0 so you can use NUnit .NET 2.0 assembly with your project.顺便说一句,使用 .NET 4.0,您可以使用任何高于 2.0 的 dll,因此您可以在您的项目中使用 NUnit .NET 2.0 程序集。 It will automatically be loaded and run with CLR v4 along with your own assemblies so no performance penalty there.它将与您自己的程序集一起自动加载并与 CLR v4 一起运行,因此不会有性能损失。

The net-2.0 version was built using .NET 2.0, but it will run successfully under .NET 4.0 (it's got entries in its.exe.config file to enable this). net-2.0 版本是使用 .NET 2.0构建的,但它会在 .NET 4.0 下成功运行(它在 its.exe.config 文件中有条目来启用此功能)。 And it will successfully run tests that were built with .NET 4.0.它将成功运行使用 .NET 4.0 构建的测试。

I agree that it would be less confusing if they provided binaries that were more obviously current, but there's no technical need for them.我同意,如果他们提供的二进制文件更明显是最新的,那就不会那么混乱了,但对它们没有技术需求。 Use the net-2.0 folder;使用 net-2.0 文件夹; it should work for you.它应该适合你。

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

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