【问题标题】:Build fails with No test is available in Test.dll VSTS NUnit test构建失败,Test.dll VSTS NUnit 测试中没有可用的测试
【发布时间】:2018-03-30 05:32:30
【问题描述】:

我是使用 .NET 和 Visual Studio 的新手。我有一个包含 NUnit 测试的项目。我正在使用 Visual Studio 2015。测试适配器通过 Nuget 包管理器进行管理,使用的版本是 3.10.1。 package.config 文件如下所示:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Autofac" version="3.5.0" targetFramework="net451" />
  <package id="AutoMapper" version="4.2.1" targetFramework="net451" />
  <package id="DelegateDecompiler" version="0.18.0" targetFramework="net451" />
  <package id="DelegateDecompiler.EntityFramework" version="0.18.0" targetFramework="net451" />
  <package id="EntityFramework" version="6.1.3" targetFramework="net451" />
  <package id="GenericLibsBase" version="1.0.1" targetFramework="net451" />
  <package id="GenericServices" version="1.0.9" targetFramework="net451" />
  <package id="log4net" version="2.0.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.SignalR.Core" version="2.0.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.Owin" version="2.1.0" targetFramework="net451" />
  <package id="Microsoft.Owin.Security" version="2.1.0" targetFramework="net451" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" />
  <package id="Mono.Reflection" version="1.0.0.0" targetFramework="net451" />
  <package id="Moq" version="4.2.1408.0717" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net451" />
  <package id="NUnit" version="3.10.1" targetFramework="net451" />
  <package id="Owin" version="1.0" targetFramework="net451" />
</packages>

.csproj 文件还包含如下参考:

<Reference Include="nunit.framework, Version=3.10.1.0, Culture=neutral, PublicKeyToken=xxxxxxxx, processorArchitecture=MSIL">

<HintPath>..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll</HintPath>
      <Private>True</Private>
    </Reference>

本地运行测试时,所有测试都执行成功。

------ Run test started ------
NUnit Adapter 3.10.0.21: Test execution started
Running all tests in <path to release>\Tests.dll
NUnit3TestExecutor converted 54 of 54 NUnit test cases
NUnit Adapter 3.10.0.21: Test execution complete
========== Run test finished: 54 run (0:00:14.202451) ==========

下一个问题是尝试在 Visual Studio Team Services (VSTS) 的 Hosted VS 2017 环境中配置相同内容,并使用可用的构建模板构建项目。构建包括以下步骤:

  1. NuGet 工具安装程序
  2. NuGet 恢复
  3. 构建解决方案
  4. 执行 VSTest
  5. 发布工件

当我触发构建时,构建在第 4 步中失败。

2018-03-29T13:18:57.8600581Z vstest.console.exe 
2018-03-29T13:18:57.8600783Z "<release path>\Tests.dll"
2018-03-29T13:18:57.8600996Z /EnableCodeCoverage
2018-03-29T13:18:57.8601174Z /logger:"trx"
2018-03-29T13:18:57.8949472Z Starting test execution, please wait...
2018-03-29T13:18:57.9616355Z Warning: Using Isolation mode to run the tests as diagnostic data adapters were enabled in the runsettings. Use the /inIsolation parameter to suppress this warning.
2018-03-29T13:19:13.6376907Z Warning: No test is available in <path to release>\Tests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
2018-03-29T13:19:13.6377691Z 
2018-03-29T13:19:13.8424412Z 
2018-03-29T13:19:13.8425192Z Attachments:
2018-03-29T13:19:13.8425592Z   <path>\buildguest_FACTORYVM-AZ49 2018-03-29 13_19_05.coverage
2018-03-29T13:19:13.8425875Z 
2018-03-29T13:19:13.8972522Z Information: Additionally, you can try specifying '/UseVsixExtensions' command if the test discoverer & executor is installed on the machine as vsix extensions and your installation supports vsix extensions. Example: vstest.console.exe myTests.dll /UseVsixExtensions:true
2018-03-29T13:19:13.9197235Z 
2018-03-29T13:19:14.3324288Z ##[warning]No results found to publish.
2018-03-29T13:19:14.4972081Z ##[section]Finishing: Test - testAssemblies

是否有遗漏的其他配置?

【问题讨论】:

    标签: asp.net-mvc continuous-integration nuget nunit azure-devops


    【解决方案1】:

    您似乎已将 NUnit 3 测试适配器作为 Visual Studio 扩展安装在本地。这将确保任何带有 NUnit 测试的项目都可以被 Visual Studio 自动发现和执行。

    但该扩展未安装在构建服务器上,您可能希望保持这种状态。

    与其在每个构建服务器上安装扩展程序并使其保持最新,不如将测试适配器作为 nuget 包添加到您的项目中,这样它就可以在构建服务器上使用而无需进一步配置。

    https://www.nuget.org/packages/NUnit3TestAdapter/

    【讨论】:

    • 是的,在 package.config 文件中添加 NUnit 3 测试适配器 &lt;package id="NUnit3TestAdapter" version="3.10.0" targetFramework="net451" /&gt; 解决了这个问题
    【解决方案2】:

    我也遇到了同样的问题。

    解决此问题的步骤 -

     1. Install/Reinstall NUnit3TestAdapter package
     2. Delete Debug folder from the Bin
     3. Clean --> Build the project
    

    注意 - 还要确保正确安装所有软件包。

    现在尝试执行测试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-17
      • 1970-01-01
      • 2021-10-11
      • 2019-03-04
      • 2012-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多