简体   繁体   中英

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.

But the strange thing is that there is no nunit.framework.dll , but there are two folders: net-1.1 and net-2.0.

I use neither, I am working in VS 2010 with .NET 4.0.

Is NUnit deprecated?

Why would they only have two folders for old versions of .NET?

To start off, NUnit is in no way deprecated and has become de facto primary unit testing framework for .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 .

However, with the release of .NET 2.0, a new CLR was shipped. 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.

When .NET 3.0 and .NET 3.5 came out, they didn't carry a new CLR along. Both of them still use .NET 2.0 CLR and only add some libraries (WPF, WCF) and language features (such as LINQ) with them. 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.

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.

There's a quote from NUnit blog explaining separate 1.1 and 2.0 packaging:

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? 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. 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. Imagine an Assert on a nullable value. Or a generic 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.

For now, the.Net 2.0 builds are identical in features to the.Net 1.1 builds. 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. 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.

(highlighting is mine)

However, it was posted a long time ago (November 2006) so probably by now the versions do differ.

Goto http://nuget.org/ and install NuGet. Then follow the instructions on how to add a NuGet package to your project. Then search for NUnit and it will automatically import the correct dll for your project.

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. It will automatically be loaded and run with CLR v4 along with your own assemblies so no performance penalty there.

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). And it will successfully run tests that were built with .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; it should work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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