Home » Testing » NUnit 2 vs NUnit 3. What you need to know.

NUnit 2 vs NUnit 3. What you need to know.

NUnit 3 recently released and if you’ve picked it up you’ve probably already found that there are several changes between version 3 and version 2.

If you haven’t, here are some highlights:


Parallel Tests

This is probably the most anticipated change.  We can finally run multiple tests at the same time.

In NUnit 3.0, we finally have the ability to run multiple tests at the same time by using the Parallelizable Attribute in combination with the LevelOfParallelism attribute.

By default, all of our tests run sequentially.  But if you’ve written your tests correctly, you should be able to run them all at the same time.  To enable this feature, you’ll need to first specify how many tests you can run at the same time by adding the LevelOfParallelism attribute to your assembly.

In your properties/AssemblyInfo.cs file add the following code:

[assembly: LevelOfParallelism(8)]

To make a test run at the same time as other tests, add the Parallelizable attribute to either the namespace, or class.  As of NUnit 3.0, running tests within a fixture in parallel is not yet supported.

The Parallelizable attribute takes one optional parameter named ParallelScope.  This option allows you to specify what level of code can run in parallel.

  • None: No tests can run in parallel
  • Self: This level can run in parallel with other similar levels
  • Children: Test under this level can run in parallel.
  • Fixtures: Only fixtures under this level can run in parallel.

Attributes applied to nested namespaces or classes override attributes applied to namespaces they are within.

Test Runner

Another big change is the test runner.  By default, the test runner is just a regular console app.  I don’t know about you, but I miss the tree view.  But it is what it is.

I would suggest that you invest in ReSharper just to get the test runner that it has.  If you can’t do that, use the MS Test Adapter from NUnit.org to run your tests in Visual Studio using the MS Test Runner.

ExpectedException Attribute

In NUnit 2, we had the option of using the ExpectedException attribute on a test that was supposed to throw an exception or we could use the Assert.That syntax that we’ve already documented.  In NUnit 3, ExpectedException is no longer available.


In NUnit 2, when we wanted to have a method that only ran once for a test class as part of setup or teardown, we would use these two attributes.  We would also use these in combination with the SetupFixture attribute to run methods once at the namespace level.

In NUnit 3, these have been replaced with OneTimeSetUp and OneTimeTearDown in both cases.

While TestFixtureSetup and TestFixtureTearDown will continue to work as part of a TestFixture, you should move to the new attributes as soon as possible.


If you specify the property to use for your tests data using a string, that property now HAS to be static.


Similarly, this now only uses a static property when specified as a string.


Several assert syntaxes have changed.  Once again, check the documentation.

For a full list of breaking changes, check out the NUnit 3 documentation.

What significant changes have you noticed? Let me know in the comments.


Other post in Testing

Related Post

  • Running Selenium In Parallel With Any .NET Unit Testing ToolRunning Selenium In Parallel With Any .NET Unit Testing Tool Running Selenium in parallel from .NET seems to be a problem because, as of the time of this writing, I’ve yet to find a viable way of running selenium test on multiple browsers using […]
  • What is SpecFlow…What is SpecFlow… …And why do I want it? That’s what I kept asking myself every time I saw this product.Well, the last time I looked, something caught my eye enough that I decided to download it and […]
  • When You Really Need All Of Your NUnit Test In One ClassWhen You Really Need All Of Your NUnit Test In One Class Last week I proposed a structure for unit test that follows the pre-condition, action, post-condition workflow.  Basically what you would see in a Use Case document. The result of […]
  • NUnit Test Code StructureNUnit Test Code Structure There are two basic ways to structure the code you will be working on to Unit test the code in your main application using NUnit.  Arrange/Act/Assert (AAA) is what I refer to as the […]
  • Run NUnit from Visual StudioRun NUnit from Visual Studio For the purposes of this post, I’m going to assume that you already have the NUnit Test Runner installed.  The question you are looking to get answered is, “How do I run NUnit from Visual […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer focusing on ASP.NET, C#, Node.js, JavaScript, HTML, CSS, BootStrap, and Angular.JS.Does your team need additional help in any of the above? Contact Dave today.