Does Visual C# 2010 Express have a unit testing feature?
9 Answers
As has been stated, the Express versions do not have any built-in, and do not allow add-ins for, this functionality, but you can use an external tool, e.g. NUnit.
You can also set up a command to run from the 'Tools->External Tools' menu option from within Visual Studio Express and run your test runner from that if you wish.
Here is a link that shows how to do it with VS C# 2008 Express, (scroll down to the end) but I think it should hold true for 2010 as well.

- 5,188
- 10
- 42
- 59
-
2Also, opening (an already open in VS Express) project in Sharpdevelop 4.0 will give an ability to run tests "visually" (the their results tied to source code) and possibly make some quick modifications to code (which will be correctly recognized by VS Express when you Alt_Tab back to it). So, the price of having a usable "visual" unit-tesing feature is about one extra Alt-Tab to SharpDevelop (and may be a click on "Run Tests"). – mlvljr Mar 06 '11 at 13:09
-
NB this won't work for VS Express for Windows Phone unless the external tool is specifically compiled for it... – funkybro Oct 12 '11 at 13:44
Nothing built in, but you can always use nUnit with it.
MSTest comes bundled with the Pro edition and above.

- 489,969
- 99
- 883
- 1,009
In 2010 it's possible using an external application, however debugging unit tests becomes difficult. If you want debugging using NUnit is probably the best route (but not the only option, see ExpressUnit). See this answer on another SO thread. It links to a blog that mentions running the test project as a console application and calling the nunit library dlls directly to launch the tests:
using System;
namespace RunTests
{
static class Program
{
[STAThread]
static void Main()
{
var args = new string[] { Assembly.GetExecutingAssembly().Location, "/run" };
NUnit.Gui.AppEntry.Main(args);
}
}
}

- 1
- 1

- 141
- 1
- 7
-
404 on the blog post. This is a great way to debug unit tests in the UI. Thanks for sharing. I ended up creating a separate project, adding a reference to the assemblies that I want to test, then using `Assembly.GetAssembly( typeof(MyAssembly.MyType)).Location` to source the assembly to the test runner. – cod3monk3y Mar 06 '14 at 17:57
Visual Studio Express editions have the limitation that plugins/addins are expressely disallowed. They do not ship with a built-in testing solution, and you cannot add-in one.
Your best/only option it to use a standalone test runner, such as nUnit, mspec, etc... and run it externally from VSE.

- 44,917
- 17
- 105
- 161
This is now included in Visual Studio 2013 Express: http://msdn.microsoft.com/en-us/library/dd264975.aspx
If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer.

- 24,742
- 13
- 105
- 107
-
It's so sad to see M$ jumping on this "testing" bandwagon just because everyone else is doing it. What a fad. (Seriously, this is 2013 and we're just getting integrated unit testing in VS??) – cod3monk3y Mar 06 '14 at 00:18
-
2@cod3monk3y, what a strange comment. It's a shame it took so long but surely it's in improvement? I'd hardly describe testing as a fad! – matt burns Mar 06 '14 at 06:51
-
1Absolutely it's an improvement! I've been developing in C# for over a decade and I'm a huge proponent of unit testing, code coverage, process, etc. So, the comment was begrudgingly sarcastic. Testing should be integral to the development process and I'm happy to see it finally become a base feature for all developers to share. I've lately been doing some Python and Angular/JS/Flask/Python programming and love how unit testing is part of the culture (`python -m unittest discover` for python and jasmine/karma for JS). Glad to see this as part of the new developers' toolkit. – cod3monk3y Mar 06 '14 at 17:42
-
This does not work in express versions. The link says nothing about express, only full versions – SwDevMan81 Aug 11 '16 at 23:11
As an update, I am currently using Visual Studio Express for Desktop
, the VS suite has been completely remodelled since 2010 and more accurately reflects the "big brother".
Unit tests are now available as a built-in feature and works the same way (I haven't tested all functionality) as Visual Studio non-Express.

- 2,400
- 2
- 12
- 22
You could always set up an additional class with a Main() method in the project and select it as a startup object in your project, and debug it from there. It might not be suitable in situation where more complex tasks is done, since you can't take advantage of the more testing-specific features but it might be useful in some simpler projects. If your project is a class library, consider convert it to an console application and then switch it back when you finished testing.

- 512
- 4
- 12
(Note : I know this post is old, but this might help someone )
As Andy posted above, you can use NUnit .
But the settings in the link posted by Andy do not work anymore in VS C# 2010.
Here are the settings I use in the External Tools window :
Command : C:\Program Files (x86)\NUnit 2.6.2\bin\nunit-x86.exe
( there is also a nunit.exe in the bin directory )
Arguments : $(ProjectDir)$(ProjectFileName)
Initial directory : $(ProjectDir)bin/Debug/$(TargetName)$(TargetExt)

- 1,228
- 10
- 17
Have a look at NHarness at codeplex, a very simple library that allows you to run NUnit test fixtures in a test project. This allows you the ability to debug through your unit tests if required
An example (from the codeplex page) of a test runner is as below
public class RunTests
{
public static void Main(string[] args)
{
TestResults results = Tester.RunTestsInClass<Tests>();
Console.WriteLine("Tests Run: {0}", results.NumberOfResults);
Console.WriteLine("Results {0}:PASSED {1}:FAILED", results.NumberOfPasses, results.NumberOfFails);
Console.WriteLine("Details:");
foreach (TestResult result in results)
{
Console.WriteLine("Test {0}: {1} {2}",
result.MethodName,
result.Result,
result.Result == TestResult.Outcome.Fail ? "\r\n" + result.Message : "");
}
Console.ReadLine();
}
}
The benefit of this library is that the TestResults class can be used to retrieve information about the tests executed, so the library can also be used in custom unit test applications

- 39,385
- 37
- 101
- 139