Testing modules in Visual C # 2010 Express?

Does Visual C # 2010 Express have unit testing functionality?

+45
c # visual-studio-express
Aug 6 '10 at
source share
8 answers

As already mentioned, Express versions do not have built-in functions and do not allow add-ons for this function, but you can use an external tool, for example. NUnit .

You can also configure the command to run from the Tools-> External Tools menu from Visual Studio Express and run your test runner if you want.

Here 's a link that shows how to do this with VS C # 2008 Express, (scroll down to the end), but I think it should be fair in 2010 as well.

Here is a new working link.

+38
Aug 6 '10 at 15:55
source share

Nothing is built in, but you can always use nUnit with it.

MSTest comes bundled with the Pro version and higher.

+10
Aug 6 '10 at 13:32
source share

In 2010, this is possible using an external application, but debugging unit tests becomes difficult. If you want debugging using NUnit probably be the best route (but not the only option, see ExpressUnit ). See this answer for another SO thread. He refers to a blog that mentions running a test project as a console application and calling the nunit DLL to run 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); } } } 
+9
Apr 03 '11 at 4:21
source share

Visual Studio Express editions have a limitation that plugins / add-ons are expressly prohibited. They do not come with a built-in test solution, and you cannot add it to one.

Your best / only option is to use a standalone test runner like nUnit, mspec etc ... and run it externally from VSE.

+8
Aug 6 '10 at 13:34
source share

It is now included in Visual Studio 2013 Express: http://msdn.microsoft.com/en-us/library/dd264975.aspx

If Tag Explorer does not appear, select Test on Visual Studio, select Windows , and then select Tester .

enter image description here

+7
Jan 14 '14 at 13:12
source share

Take a look at NHarness at codeplex, a very simple library that lets you run NUnit test instruments in a test project. This allows you to debug your unit tests if required.

Example (from the codeplex page) of a test runner 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 advantage of this library is that the TestResults class can be used to retrieve information about completed tests, so the library can also be used in custom unit test applications

0
Dec 01 2018-11-12T00:
source share

You can always configure an additional class using the Main () method in the project and select it as the launch object in your project and debug it from there. This may not be suitable in situations where more complex tasks are performed, since you cannot take advantage of more testing-specific functions, but it may be useful in some simpler projects. If your project is a class library, consider converting it to a console application and then return it when you finish testing.

0
Dec 02
source share

(Note: I know this post is old, but it might help someone)

As Andy said above, you can use NUnit .
But the settings in the link posted by Andy no longer work in VS C # 2010.
Here are the settings that I use in the External Tools window:

Command: C: \ Program Files (x86) \ NUnit 2.6.2 \ bin \ nunit-x86.exe
(the bin directory also has nunit.exe)

Arguments: $ (ProjectDir) $ (ProjectFileName)
Start Directory: $ (ProjectDir) bin / Debug / $ (TargetName) $ (TargetExt)

0
Jun 09 '13 at 20:39
source share



All Articles