Coder Perfect

For unit testing, NUnit vs. Visual Studio 2008’s test projects [closed]


I’m starting a new project at work and want to learn more about unit testing. We’ll be working with Visual Studio 2008, C#, and the ASP.NET MVC framework. I’m considering utilizing NUnit or the built-in test projects in Visual Studio 2008, but I’m willing to look into other options. Is one system superior than the other in terms of performance or ease of use/understanding?

I’d like to establish this project as a form of “best practice” for our future development efforts.

Asked by Ryan Skarin

Solution #1

All of the advantages of Visual Studio 2008 test projects were listed by Daok. The advantages of NUnit are listed below.

Answered by Mendelt

Solution #2

Because you can transform test classes with separate project files and conditional compilation (like this, Visual Studio NUnit), the unit-testing framework doesn’t really matter.

 #if !NUNIT
  using Microsoft.VisualStudio.TestTools.UnitTesting;
  using NUnit.Framework;
  using TestClass = NUnit.Framework.TestFixtureAttribute;
  using TestMethod = NUnit.Framework.TestAttribute;
  using TestInitialize = NUnit.Framework.SetUpAttribute;
  using TestCleanup = NUnit.Framework.TearDownAttribute;
  using TestContext = System.String;
  using DeploymentItem = NUnit.Framework.DescriptionAttribute;

The TestDriven.Net plugin is attractive and reasonably priced… You must find the test from your test class or test list if you are using merely basic Visual Studio 2008. You can run your test directly from the class you’re testing with TestDriven.Net. Unit tests, after all, should be simple to maintain and close to the developer.

Answered by Tuomas Hietanen

Solution #3

The built-in unit testing framework in Visual Studio 2008 has the following advantages and changes:

Answered by Simara

Solution #4

For the past two years, I’ve been using NUnit. Everything is OK, but I have to mention that Visual Studio’s unit testing mechanism is rather nice because it is integrated into the GUI and allows you to easily test private functions without having to fiddle with the code.

Additionally, Visual Studio’s unit testing allows you to perform covering and other tasks that NUnit alone cannot.

Answered by Patrick Desjardins

Solution #5

Visual Studio’s testing framework has one minor drawback: it creates a lot of test run files, which can clutter your project directory. However, this isn’t a significant concern.

Additionally, if you don’t have a plugin like TestDriven.NET, you won’t be able to debug your NUnit (or MbUnit, xUnit, or other) unit tests within the Visual Studio environment, as you can with the built-in Microsoft Visual Studio testing framework.

Answered by Tarsier

Post is based on