Adding NUnit to the options for ASP.NET MVC test framework

After a bunch of research and experimentation, I’ve found the answer. For the record, the current release of nUnit 2.5 Alpha does not seem to contain templates for test projects in Visual Studio 2008. I followed the directions here which describe how to create your own project templates and then add appropriate registry entries that … Read more

xUnit framework: Equivalent of [TestFixtureSetUp] of NUnit in XUnit?

There is no direct equivalent of [TestFixtureSetUp] in XUnit, but you can achieve similar functionality. This page lays out the translation between NUnit and XUnit (as well as a couple other C#/.NET test frameworks). However, XUnit largely got rid of setups/teardowns (this article explains why that decision was made). Instead, you need the test suite … Read more

Using MS Test ClassInitialize() and TestInitialize() in VS2010 as opposed to NUnit

Here is a simple example using TestInitialize and TestCleanup. [TestClass] public class UnitTest1 { private NorthwindEntities context; [TestInitialize] public void TestInitialize() { this.context = new NorthwindEntities(); } [TestMethod] public void TestMethod1() { Assert.AreEqual(92, this.context.Customers.Count()); } [TestCleanup] public void TestCleanup() { this.context.Dispose(); } }

Why testFixture instead of TestClass?

I respect Mike Two’s response, but I would assert that the NUnit team got this very wrong, and the use of [TestFixture] is a semantic wart on the face of NUnit. A test class is not a fixture. From what I’ve dug into with regard to JUnit, I have not found any reference to a … Read more

VS 2010, NUNit, and “The breakpoint will not currently be hit. No symbols have been loaded for this document”

There’s another similar question here on Stack Overflow, where I posted my answer with what worked for me. I can set breakpoints and start NUnit directly from Visual Studio 2010 with Debug -> Start New Instance (which I think is your goal). I set nunit.exe as the external program in project -> Properties -> Debugging … Read more