xUnit异步测试显示为“外部"(External).在VS2015中 [英] xUnit async tests shows up as "External" in VS2015

查看:56
本文介绍了xUnit异步测试显示为“外部"(External).在VS2015中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所有的异步xUnit测试在VS2015的测试资源管理器"中都显示为外部"时遇到问题.当在测试资源管理器中调用全部运行"时,它们仍将运行,但是由于它们被认为是外部的,因此几乎所有VS2015集成都无法正常工作,例如导航(单击测试资源管理器以进行测试)不起作用,上下文菜单中的运行/调试测试"将永远不会触发测试,测试状态图标不会显示,并且Code Lens也不会找到这些测试.

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);
    }

我正在运行VS2015的RTM版本,并将xunit.runnet.aspnet 2.0.0-aspnet-beta6程序包安装到我的项目中.

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

关于如何解决此问题的任何建议,或者这仅仅是一个错误?在那种情况下,可能是xUnit测试运行程序问题还是VS2015中的问题?

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?

推荐答案

此错误已在ASP.NET 5 beta7版本中得到确认并修复.

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

有关其他信息,请参见以下github问题:

For additional information see the following github issues:

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

这篇关于xUnit异步测试显示为“外部"(External).在VS2015中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆