31

Is it possible to use the integrated Visual Studio 2010 test runner to run other frameworks (Xunit, NUnit etc.) besides MSTest?

Does anyone know?

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
Thomas
  • 5,888
  • 7
  • 44
  • 83

8 Answers8

32

No but you can add an external tool. Go to Tools | External Tools... and click Add

Title: xUnit Test

Command: xunit.console.exe (set to full path to console test runner)

Arguments: $(BinDir)$(TargetName)$(TargetExt)

Initial directory: $(BinDir)

Click Use Output Window

Click OK. This adds the xUnit Test command to the Tools menu.

You can then create a shortcut key to making running the external tool easier. eg: Ctrl +T

MW_dev
  • 2,146
  • 1
  • 26
  • 40
  • Great. +1. I've never used external tools - is there a way to add the html output file into the arguments? This is what I put into my cmd line normally: /html test.html – adrianos May 09 '11 at 10:55
  • 1
    Ignore my q. If I put $(BinDir) in the 'Initial directory' textbox, it works a treat and adds /writes to the file in my bin directory – adrianos May 09 '11 at 11:02
  • 2
    -1 and I urge every one to do the same. Of course it IS POSSIBLE. It is just a problem of having a proper plugin! Pah, even the VisualStudioExtensibility code samples contain a sample of how to build your own test case handlers. Please see PaulMillsaps's and especially Raj's answers - http://xunit.codeplex.com/workitem/5648 – quetzalcoatl Mar 26 '12 at 16:34
  • by the way, instead of adding it as external tool, you can inject a MSBuild task that will run tests at every, for example, 'release' build. – quetzalcoatl Mar 26 '12 at 16:37
  • @quetzalcoatl: The question is specifically referencing 2010. On the page you reference Brad Wilson specifically says: An experimental Visual Studio 11 runner has been shipped, and our strategy for Visual Studio integration is to support Visual Studio 11 (and later) upon RTM. – MW_dev Mar 29 '12 at 02:56
  • 2
    please read it further below! **BradWilson** said that they (xUnit's team) will not support the 2010 plugin, created and sent **a year earlier** by **EmperorXLII**, because they are not in mood for it. That's right! But does that cancel the fact that the plugin **works** and allows running them? In very basic way, but allows, and displays/filters result, etc. Anyways, the question was not whether they do support, but whether it is possible. The answer is: it is, because the test framework in VS is (somewhat) extensible and Emperor proved it 1.5 yrs ago – quetzalcoatl Mar 30 '12 at 14:34
6

At this stage xUnit doesn't support MSTest runner. However there is an extension someone already created. Few limitations, but you can run xUnit Tests within VS. For more information please see the link below. http://xunit.codeplex.com/workitem/5648

Spock
  • 7,009
  • 1
  • 41
  • 60
  • +1 The OA didn't want the MSTest to run xUnit's test. He wanted a test runner for xUnit and the http://xunit.codeplex.com/workitem/5648 is actually IT :) – quetzalcoatl Mar 26 '12 at 16:35
6

A bit late maybe, but this post shows in Google so I thought it might be worth to mention that ReSharper's unit test runner can integrate xUnit tests using the xUnit.net Contrib project, found here: http://xunitcontrib.codeplex.com/

Max
  • 3,280
  • 2
  • 26
  • 30
3

There is an addon called 'Visual NUnit 2010' that will run NUnit tests in VS2010. It adds a TestRunner window that allows you to see your test results. More informations is at http://www.bubblecloud.org/visualnunit.

  • You can install this in VS2010 by using Tools > Extension Manager, then just type 'Visual NUnit 2010' After restarting VS2010 either press CTRL+F7 or Open the view from View -> Other Windows -> Visual Nunit – Charlie Barker Oct 19 '11 at 21:38
1

Adam Salvo made the start of an XUnit test runner based on the NUnit one: see http://blog.salvoz.com/2010/02/22/TransformXUnitToMSTest.aspx

AllWorkNoPlay
  • 454
  • 1
  • 4
  • 20
0

FYI - If you install Gallio / MbUnit you can run almost any type of test in Visual Studio 2010.

digiguru
  • 12,724
  • 20
  • 61
  • 87
0

So far as I know, you can't use xUnit in any VS version right now.

C.C.
  • 1,060
  • 3
  • 13
  • 25
0

NUnitForVS allows running NUnit tests using the integrated VS 2010 test runner. Many VS test features work, including Code Coverage, debugging, and running currently edited test method. There are some rough edges, but overall the extension works nicely.

Jakub Berezanski
  • 1,053
  • 9
  • 13