mpen
mpen

Reputation: 283355

C# .NET 4.0 Testing Framework?

If I'm not mistaken, NUnit is the de-facto standard for unit testing, but I've just downloaded it, wrote a simple test, and then apparently I have to fire up the GUI and load my .exe assembly, which simply failed.

I tried editing

C:\Program Files (x86)\NUnit 2.5.7\bin\net-2.0\nunit.exe.config

As suggested in this question, but that didn't work either, so I tried downloading the nunit source code and compiling it in vs2010, but it doesn't even compile. Says punit.framework.dll could not be found. That solution says "does not contain a definition for AllTestsExecuted", so I'm getting a little frustrated here. You'd think there would be an easy-to-use-and-get-running framework for .net 4, no?

So my question is, how do I either get NUnit working, or is there another framework that will cause me less agony?

Upvotes: 3

Views: 4635

Answers (6)

Jason Evans
Jason Evans

Reputation: 29186

You don't have to use the NUnit GUI to run your tests. You can use TestDriven.NET from within Visual Studio. Also, if you happen to be using Resharper, that has a unit test runner which works with NUnit also.

Upvotes: 4

Frank Schwieterman
Frank Schwieterman

Reputation: 24478

For NUnit's GUI test runner, make sure you've selected the right framework version. Its in the "File" menu. If your test or any dependencies are 32-bit be sure you're running the 32bit version of the test runner.

Testdriven.net is a better test runner, but I like using NUnit's GUI runner too at times.

Upvotes: 1

Peter C
Peter C

Reputation: 6307

I am not a C# programmer (fortunately ;-) ) but I've heard good things about xUnit. Tests can be run pretty much however you want (command line, GUI, Visual Studio integration, and more) and it looks reasonable simple to use.

Upvotes: 1

devoured elysium
devoured elysium

Reputation: 105227

If you use Visual Studio 2010, you can use MSTest. Just click CTRL + ALT + R and it will run your tests and show the results in Visual Studio itself.

That same test-runner will also work for NUnit, if I am not mistaken.

Upvotes: 0

Nobody
Nobody

Reputation: 4841

NUnit is infact very simple to use, so I would say that it's more likely that you are making a mistake somewhere, not the software.

Make sure you follow this guide.

  • Ensure that you have the [TestFixture] and [Test] attributes in the correct places and all the relevant assemblies referenced.
  • Make sure that you are loading the correct dll in the NUnit GUI.

If its the GUI that is the issue, you can use Resharper's unit testing feature in stead.

Upvotes: 0

Steve Danner
Steve Danner

Reputation: 22198

If you're not doing anything out of the ordinary, I recommend Microsoft's Unit Testing Framework. I find it's VS integration too easy to even worry about NUnit. I agree NUnit seems to be the defacto standard, but if you're looking for something quick and easy. Microsoft's way is the easiest for a typical Visual Studio programmer IMHO.

Upvotes: 2

Related Questions