xUnit async tests shows up as “External” in VS2015

こ雲淡風輕ζ 提交于 2019-12-20 02:52:46

问题


I have problems with all my async xUnit tests showing up as External in the Test Explorer in VS2015. They will still run when calling Run All in the test explorer, but as they are considered external almost all of the VS2015 integration does not work, e.g. the navigation (click in test explorer to get to test) is not working, the Run/Debug Tests in the context menu never triggers the test, test status icons doesn't show and Code Lens won't find these tests.

The async tests are using the following pattern:

    [Fact]
    public async Task AsyncTestMethod()
    {
        // Arrange
        var sot = new Sot();

        var result = await sot.DoAsync();

        Assert.NotNull(result);
    }

Changing the test to run in-sync fixes all these problems:

    [Fact]
    public void SyncTestMethod()
    {
        // Arrange
        var sot = new Sot();

        var result = sot.DoAsync().Result;

        Assert.NotNull(result);
    }

I'm running the RTM version of VS2015 with the xunit.runnet.aspnet 2.0.0-aspnet-beta6 package installed into my project.

Any suggestion on how this can be solved or is this simply a bug? And in that case, is it likely a xUnit test runner issue or a problem in VS2015?


回答1:


This bug was confirmed and fixed in the ASP.NET 5 beta7 version.

For additional information see the following github issues:

  • https://github.com/aspnet/Tooling/issues/130
  • https://github.com/aspnet/Testing/issues/86


来源:https://stackoverflow.com/questions/31799380/xunit-async-tests-shows-up-as-external-in-vs2015

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!