C# VS2013测试资源管理器中未列出等待的异步NUnit测试

C# VS2013测试资源管理器中未列出等待的异步NUnit测试,c#,visual-studio-2013,nunit,async-await,.net-4.5,C#,Visual Studio 2013,Nunit,Async Await,.net 4.5,我遇到了以下问题。测试资源管理器中未列出使用wait等待返回GetCustomDataAsync的调用的NUnit异步测试。同样,异步测试等待返回int-GetDataAsync的调用显示在测试资源管理器中。我将问题分解为以下最小代码示例: public class CustomClient { public async Task<int> GetDataAsync(int a, int b) { int result = a + b;

我遇到了以下问题。测试资源管理器中未列出使用wait等待返回GetCustomDataAsync的调用的NUnit异步测试。同样,异步测试等待返回int-GetDataAsync的调用显示在测试资源管理器中。我将问题分解为以下最小代码示例:

public class CustomClient
{
    public async Task<int> GetDataAsync(int a, int b)
    {
        int result = a + b;
        // doing some work async
        await Task.Delay(250);
        return result;
    }

    public async Task<CustomClass> GetCustomDataAsync(int count)
    {
        CustomClass result = new CustomClass(count);
        // doing some work async
        await Task.Delay(250);
        return result;
    }
}

public class CustomClass
{
    private int _count;
    public CustomClass(int count)
    {
        _count = count;
    }

    public int Count
    {
        get { return _count; }
        set { _count = value; }
    }
}

[TestFixture]
public class CustomClientUnitTests
{
    [Test]
    public async Task TestListedInTestExplorer()
    {
        int a = 2;
        int b = 3;
        int expectedResult = 6;

        CustomClient sut = new CustomClient();
        int result = await sut.GetDataAsync(a, b);

        Assert.That(result, Is.EqualTo(expectedResult));
    }
    [Test]
    public async Task Test_NOT_ListedInTestExplorer()
    {
        int inCount = 5;
        int expectedOutCount = 6;

        CustomClient sut = new CustomClient();
        CustomClass customResult = await sut.GetCustomDataAsync(inCount);

        Assert.That(customResult.Count, Is.EqualTo(expectedOutCount));
    }
}
公共类客户机
{
公共异步任务GetDataAsync(int a,int b)
{
int结果=a+b;
//异步做一些工作
等待任务。延迟(250);
返回结果;
}
公共异步任务GetCustomDataAsync(整数计数)
{
CustomClass结果=新CustomClass(计数);
//异步做一些工作
等待任务。延迟(250);
返回结果;
}
}
公共类CustomClass
{
私人国际单位计数;
公共自定义类(整数计数)
{
_计数=计数;
}
公共整数计数
{
获取{return\u count;}
设置{u count=value;}
}
}
[测试夹具]
公共类CustomClientUnitTests
{
[测试]
公共异步任务TestListedTestExplorer()
{
INTA=2;
int b=3;
int expectedResult=6;
CustomClient sut=新的CustomClient();
int result=await sut.GetDataAsync(a,b);
Assert.That(result,Is.EqualTo(expectedResult));
}
[测试]
公共异步任务测试\u未\u ListedInTestExplorer()
{
int inCount=5;
int expectedOutCount=6;
CustomClient sut=新的CustomClient();
CustomClass customResult=await sut.GetCustomDataAsync(inCount);
Assert.That(customResult.Count,Is.EqualTo(expectedOutCount));
}
}
CustomClient和CustomClass位于类库中。单元测试也在单独的类库中。我在UnitTest项目中添加了对生产代码的引用

在UnitTest项目中,我安装了以下NuGet软件包:

  • 适用于VS2012和VS2013的NunitestAdapter,v1.2

  • 努尼特,v2.6.4

到目前为止,我已经尝试过了,但没有成功:

  • 已启动VS2013,具有/不具有管理员权限

  • 各种“清洁解决方案”和“构建/重建解决方案”

  • 更改了测试->测试设置->默认处理器体系结构:x86/x64

  • 将第二个单元测试移动到另一个单元测试类

我错过了什么,还是做错了?为什么VS2013测试资源管理器中没有列出第二个异步单元测试

编辑

我已经做了进一步的测试,试图找出问题:

  • 使用MSTest而不是NUnit,async/await方法可用于两个单元测试,这两个测试按预期在测试资源管理器中列出

  • 使用ReSharper 9(使用当前演示版本/试用版)作为测试资源管理器/运行器和NUnit,这两个测试都会按预期在ReSharper单元测试资源管理器中列出

到目前为止,它看起来像是NUnit和VS2013测试资源管理器的问题,具体来说,我认为是“集成”(NUnit Test Adapter for VS2013?)的问题


有人已经看到这个问题了吗?或者有其他信息吗?

我也收到了这个问题。在输出窗口中,它为每个
async
测试显示一个错误:
Exception System.IO.FileNotFoundException,异常转换[test name]
@AJRichardson不确定当时的问题是什么。但是(后来…)我也有一些奇怪的问题,因为路径中有特殊的角色。就我而言,这是一个“#”。我建议创建或移动(新)项目到没有任何特殊字符的位置/路径。谢谢你的建议。但是我的路径中没有任何特殊字符(甚至没有空格)。