Support VSTS Test Runner


Run xUnit.net tests using the runner built into Visual Studio.

file attachments

Closed Nov 25, 2011 at 6:07 PM by BradWilson
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.


rcasady616 wrote Jul 21, 2009 at 8:23 PM

Any idea if this will be on any future raodmap?

BradWilson wrote Jul 21, 2009 at 11:03 PM

It's definitely something we're interested in doing, but we don't have a firm timeline for it yet. One of the big decisions is what version of Visual Studio we target to make this feature happen.

bartelink wrote Sep 24, 2009 at 9:11 AM

I've often found having auto-rerun in a separate console when one builds an excellent substitute - see http://xunit.codeplex.com/WorkItem/View.aspx?WorkItemId=8832
Especially as 2K8 hasnt got multimon yet :D

bartelink wrote Sep 24, 2009 at 9:14 AM

Also, there is resharper runner support already
CR is getting support: See also http://community.devexpress.com/blogs/aspnet/archive/2009/09/02/coderush-upcoming-testrunner-preview.aspx

And TestDriven.NET is well worth a try too if you dont want to use either of the above

jgauffin wrote Oct 12, 2010 at 7:56 AM

any updates? :)

EmperorXLII wrote Nov 13, 2010 at 4:16 PM

I have attached a VS2010 extension that I've been working on for the past couple weeks to integrate xunit into MSTest. It includes the code and binaries for a heavily modified version of the "Custom Test Type Extensibility Sample" on the VS extensability page (http://msdn.microsoft.com/en-us/vstudio/ff420671.aspx), with inspiration from the NUnitForVS extension for VS2008 (http://nunitforvs.codeplex.com/).

To be clear, this is BETA QUALITY at best. It is able to run all xunit Fact and Theory tests, display results just like MSTest's data-driven test, and is compatible with VS's Code Coverage feature (and likely others). This met our immediate needs, but there are some caveats (below). If these are acceptable, feel free to use the extension or code as you see fit. The extension can be installed by running the install.bat file in the Exports directory from a VS2010 admin command prompt. See the NUnitForVS page for how to update existing projects to show up as test projects in VS (the ProjectTypeGuids section).

Known issues:
  • Methods in a class must have a unique name (i.e. you cannot have multiple Theory methods with the same name but different arguments).
  • Clicking "Open Test" or double-clicking a test will not take you to the test.
Other miscellaneous implementation details:
  • The implementation required a one-line modification to ExecutorWrapper.cs in xunit.runner.utility.dll, to work around an unknown incompatibility with using the new IMessage-based remoting when hosted by VS (the one-line change adds support for an environment variable flag to force using the legacy callback mechanism; see Imports in the download).
  • The results are displayed with the actual private MSTest result types using reflection.

rajithakba wrote Apr 26, 2011 at 8:26 PM

Few limitations with this extension, but it covers the immediate needs. I personally like it.
xUnit devs use third party runners such as TestDriven.NET / R# to run tests within VS. But if xUnit has an integrated VS2010 runner, then lot of developers will start using xUnit. Which also mean better Unit Tests.

jgauffin wrote May 10, 2011 at 10:58 AM

Emporor: Do you have a repository for the extension?

EmperorXLII wrote May 17, 2011 at 10:38 PM

Sorry for taking so long to get back to you. I do not have a public repository for the extension; I just include all the code as well as the exported binaries in the attachment.

Also, I have made some improvements to the code, correcting a serialization issue with opening saved .trx files, and using the Owner field to allow grouping tests by class. Same caveats as before apply to the new 1.2 version.

quetzalcoatl wrote Apr 1, 2012 at 11:42 PM

I know that this issue is closed, but if anyone is interested in the runner for 2010, please check:

https://github.com/quetzalcoatl/xvsr10/ - the repository
https://github.com/quetzalcoatl/xvsr10/tree/master/Exports - prebuilt binaries
http://quetzalcoatl-pl.blogspot.com/search/label/xvsr10 - details [LONG]

Installation is manual as before. Please read the instructions.

It now supports RunFromContext, Jumping back and forth between code and tests, and provides data for many more columns of the test list and test results views.