Cannot run Xunit with Visual Studio 2013 Community

2019-07-07 04:42发布

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?

3条回答
小情绪 Triste *
2楼-- · 2019-07-07 05:06

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.

查看更多
何必那么认真
3楼-- · 2019-07-07 05:06

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.

查看更多
男人必须洒脱
4楼-- · 2019-07-07 05:18

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

查看更多
登录 后发表回答