VSTS 中 .NET Core 1.1 上的 Dotnet 测试:未注册测试发现者

Dotnet test on .NET Core 1.1 in VSTS: No Test Discoverer is Registered

我在 .NET Standard class 库中使用 VS 2017 和新的 csproj,尝试使用 MSTest 测试框架和 dotnet test 命令。 运行 在本地工作得很好;当我将构建发送到持续集成时,出现错误:

No test discoverer is registered to perform discovery of test cases.

如何在 VSTS 中注册此发现者和我的测试 运行?

参考以下步骤:

  1. 用MSTest测试框架新建.Net Core测试项目,有MSTest.TestAdapter和MSTest.TestFramework包引用,很重要
  2. 添加 .NET Core(预览版)步骤(命令:恢复)
  3. 添加 .NET Core(预览版)步骤(命令:构建)
  4. 添加 .NET Core(预览版)步骤(命令:测试)
  5. 使用 Hosted VS2017 构建代理排队构建。

这是我在 VSTS 上的构建过程 (detailed on my blog here)

  1. 添加一个 dotnet restore 任务。
  2. 然后是dotnet build任务。
  3. 添加参数为 --no-build --logger "trx;LogFileName=tests-log.trx
  4. dotnet test 任务
  5. 使用以下设置添加 Publish test results 任务

  1. Test Result Format = VSTest
  2. Test Result Files = **/测试-log.trx
  3. Merge Test Results =(选中)
  4. Control Options 中将 Run this task 设置为 运行 即使之前的任务失败了