NUnit 3 was recently released, bringing parallel execution and extensibility to the .NET testing framework. InfoQ reached out with Charlie Poole, maintainer of NUnit for over 10 years, to learn more about this release.
InfoQ: After 2 years of development, releasing five alphas, five betas and two release candidates, the final version was released last month. What were the main goals of this major version?
Charlie Poole: Well, before answering that, I have to tell you it was really much longer than it would appear, based on the released alphas and betas. My first ideas for NUnit 3.0 were made public at the 2007 Mono Summit in Madrid. The guys working on Mono were a great audience and gave me lots of ideas. Frankly, they were much more ready to think "outside the box" than the general .NET community of the time.
NUnit is now 15 years old. Basically the goal of this release is to get NUnit ready for the next 10 years. NUnit 2.0 was a complete rewrite in 2002. This is the second complete rewrite. When we say major, we mean it!
To make NUnit able to move forward, I felt that it had to become much more modular. We want to make it into a true testing platform, rather than just a framework, while still allowing folks who only want a simple framework to use it in that way. That means we will have to add features that support more kinds of tests than just unit tests. The 3.0 release has a pretty nice set of features, but I think those are just the tip of the iceberg.
Now that the production 3.0 release is out, we'll start releasing much more rapidly - as we have for NUnit V2 over the past decade or so. In fact, we just put out NUnit 3.0.1, a bug fix release.
InfoQ: What would be the most requested features of this release?
CP: One of the biggest is parallel test execution, controlled by attributes. We support two levels of parallelism: multiple assemblies in separate processes and multiple threads within a process. Each of them is useful in different circumstances.
Another major feature is that NUnit now has a TestEngine with a published API that allows anyone to write a program to run tests. In the past, this didn't exist and any code you wrote to run tests in NUnit programmatically had to use internal classes that were subject to change from release to release. That has made life hard for third party runner developers.
A third feature is extensibility. NUnit V2 had "NUnit addins" which were very complex to write. NUnit 3.0 has eliminated those and supports two levels of extensibility:
- By creating a new attribute at the framework level and implementing certain defined interfaces to give the desired behavior. This approach, by the way, was inspired by MbUnit - sharing ideas is one of the ways Open Source contributes to innovation.
- By creating a plugin for the engine.This allows extending NUnit in a "bigger" way. For example, an engine driver extension allows NUnit 3.0 to execute NUnit V2 tests. You could write such an extension for xUnit, msTest or even junit if you cared to. This is also the facility we will leverage to allow running tests remotely or on devices in future releases.
InfoQ: What new platforms are supported in NUnit 3?
CP: We now have a portable library build of the framework, which allows it to run tests under NET 4.5+, .NET Core (Universal Windows Apps 10+, DNX Core 5+), Windows 8, Windows Phone 8 (Silverlight), Universal (Windows Phone 8.1+, Windows 8.1+) and Xamarin (MonoTouch, MonoAndroid, Xamarin iOS Universal).
Of course, various legacy platforms are still supported as well, including .NET 2.0, Silverlight and .NET CF 3.5. We have finally dropped support for .NET 1.1 and .NET CF 2.0.
InfoQ: What accomplishment are you the most proud of?
CP: Keeping NUnit alive! Starting around 2005, folks started predicting the demise of NUnit. The biggest factor was the arrival of an "official" Microsoft test framework, which it was claimed would drive all the open source unit test projects out of business. Not only didn't this happen, but the predictions of our death provided the impetus for a lot of innovation and, specifically, for designing the NUnit Test Development Platform, aka NUnit 3.0.
A second major accomplishment has been to find and keep the support of a great body of committers, contributors and community members. As a technical guy, this sort of community-building doesn't come natural to me, so I'm naturally proud to have mastered it a little. At 73, I doubt I'll want to work on NUnit beyond 2020 or so, so I'm glad there are others to keep it going! In particular, Rob Prouse has become co-owner of the project on GitHub and has done a great job in managing several releases.
InfoQ: Anything you would like to add?
CP: Back in 2002, I was looking for an Open Source test project to use for my work.I mainly adopted NUnit because of the team of guys working on it. Eventually, I joined the project and, as it turns out, I'm the last of that bunch still in the room. It's fortunate that others have joined the team, so I won't have to turn the lights out when I leave.
NUnit source code can be found on GitHub. The repository also contains documentation on NUnit 3, including an upgrade guide.