我使用.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环境中配置相同的内容,并使用可用的构建模板构建项目。构建包括以下步骤:
当我触发构建时,构建在步骤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
是否需要遗漏任何其他配置?
答案 0 :(得分:1)
看起来您已在本地安装了NUnit 3测试适配器作为Visual Studio扩展。这将确保任何具有NUnit测试的项目都可以由Visual Studio自动发现和执行。
但是构建服务器上没有安装该扩展,您可能希望保持这种方式。
不是在每个构建服务器上安装扩展并使其保持最新,而是将测试适配器作为nuget包添加到项目中的更好的解决方案,这样它将在构建服务器上可用而无需进一步配置。
答案 1 :(得分:0)
我也遇到了同样的问题。
解决此问题的步骤-
1. Install/Reinstall NUnit3TestAdapter package
2. Delete Debug folder from the Bin
3. Clean --> Build the project
注意-还要确保所有软件包都已正确安装。
现在尝试执行测试。