3

I'm trying to get XUnit to work with Visual Studio 2013 Community (Version 12.0.31101.00 Update 4).

I've got NUnit to work so I thought it would be simple to get XUnit to work.

The code is

using Xunit;

namespace Xunit
{
    public class Class1
    {
        [Fact]
        public void myFirstTest()
        {
            Assert.False(true);
        }
    }
}

I've used the NuGet Package manager to install the following.

XUnit.net is version 1.9.2

XUnit.net: Runners is version 1.9.2

I've seen videos of people running XUnit with VS2012 but no one with 2013.

Any ideas?

Community
  • 1
  • 1
Alan
  • 306
  • 2
  • 10

3 Answers3

3

You need to install the "xunit.runner.visualstudio" as a nuget package, currently in beta, so run in package manager console:

Install-Package xunit.runner.visualstudio -Pre

or look for it in the GUI, but do select "include prerelease" as explained in the new docs.

robi-y
  • 1,687
  • 16
  • 25
  • Hi, Interesting, I didn't get an email saying this was replied to! I just had another look today on Xunit and found that 2 days ago, 20 Jan 2015, that they have released "Visual Studio Runner 2.0 RC1". This is now picking up the Xunit tests in VS2013 Community, which release 1.92 wasn't. However, as of today, 22 Jan 2015, "xUnit.net 2.0 RC 1" is failing to install via the NuGet package manager, complaining about the specified path, filename is too long. I guess I will have to wait a bit long for them to sort things out. Alan – Alan Jan 22 '15 at 10:32
  • Here's the error via the console: PM> Install-Package xunit -Pre Attempting to resolve dependency 'xunit.core (= 2.0.0-rc1-build2826)'. Install-Package : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. At line:1 char:16 + Install-Package <<<< xunit -Pre + CategoryInfo : NotSpecified: (:) [Install-Package], PathTooLongException + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand – Alan Jan 22 '15 at 10:38
1

OK - as of today, 20 Jan 2015, I have managed to get Xunit working on VS2013 Community with the stable 1.9.2 Xunit.net and the pre-release "Visual Studio Runner 2.0 RC1".

  • 1.9.2 Xunit visual studio runner, didn't pick up xunit tests in Test Explorer
  • 2.0RC1 Xunit.net installation fails complaining about filename/path is too long.

But the combination of 1.9.2 Xunit.net & 2.0RC1 Xunit Studio Runner works well for me. I guess tomorrow! or whenever they release the final version of Xunit, I can replace 1.9.2 Xunit.net with the latest.

Alan
  • 306
  • 2
  • 10
  • 1
    Some solutions are suggested on this issue comments https://github.com/xunit/visualstudio.xunit/issues/34 – robi-y Jan 24 '15 at 16:19
0

it may be the option under Test->Test Settings-> Keep test execution engine running. If you have both MSTEST and XUNIT, it has a problem switching.

Also if resharper is installed you can Uncheck enable unit tests through the options. though this seems to be mostly with resharper 8.1

Also found had to move xunits out of Test project and even then this is hit or miss.

keyword: executor://xunit/VsTestRunner2

Mark Rowe
  • 919
  • 9
  • 7