NUnit测试在ReSharper(单元测试会话窗口)中工作,但Visual Studio和托管VSTS构建代理无法找到任何测试

时间:2018-02-23 23:06:25

标签: visual-studio unit-testing visual-studio-2017 nunit nunit-3.0

我刚刚选择了一个旧的(ish)项目,该项目已经注释了大量的单元测试。我想恢复测试,并增加代码覆盖率,以便我们可以使用TDD进行破解。

我正在运行VS2017(15.5.7),ReSharper 2017.3.2,dotCober 2017.3.2 - 所有最新版本。该项目是Framework v4.7.1(从4.5.2升级)。我已经在VS中安装了NUnit3 Test Runner Extension。

这是一个干净的Windows安装,因此没有旧的垃圾。

示例packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Castle.Core" version="3.3.3" targetFramework="net452" />
  <package id="Castle.Windsor" version="3.3.0" targetFramework="net452" />
  <package id="EntityFramework" version="6.1.3" targetFramework="net452" />
  <package id="Microsoft.CodeCoverage" version="1.0.3" targetFramework="net471" />
  <package id="Microsoft.NET.Test.Sdk" version="15.6.0" targetFramework="net471" />
  <package id="Microsoft.VisualStudio.TestPlatform" version="14.0.0.1" targetFramework="net471" />
  <package id="Moq" version="4.2.1510.2205" targetFramework="net452" />
  <package id="NUnit" version="3.9.0" targetFramework="net471" />
  <package id="NUnit.Console" version="3.8.0" targetFramework="net471" />
  <package id="NUnit.ConsoleRunner" version="3.8.0" targetFramework="net471" />
  <package id="NUnit.Extension.NUnitProjectLoader" version="3.5.0" targetFramework="net471" />
  <package id="NUnit.Extension.NUnitV2Driver" version="3.6.0" targetFramework="net471" />
  <package id="NUnit.Extension.NUnitV2ResultWriter" version="3.5.0" targetFramework="net471" />
  <package id="NUnit.Extension.TeamCityEventListener" version="1.0.3" targetFramework="net471" />
  <package id="NUnit.Extension.VSProjectLoader" version="3.7.0" targetFramework="net471" />
  <package id="NUnit3TestAdapter" version="3.9.0" targetFramework="net471" />
</packages>

这是在我将所有软件包升级到最新版本之后。

与之一起使用的.csproj是:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..\packages\Microsoft.NET.Test.Sdk.15.6.0\build\net45\Microsoft.Net.Test.Sdk.props" Condition="Exists('..\packages\Microsoft.NET.Test.Sdk.15.6.0\build\net45\Microsoft.Net.Test.Sdk.props')" />
  <Import Project="..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" />
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{F46BC342-E486-4EF2-8C52-6B7CEF6D9565}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>MyProject.ServiceTests</RootNamespace>
    <AssemblyName>MyProject.ServiceTests</AssemblyName>
    <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile />
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Development|AnyCPU'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\Development\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|AnyCPU'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\Test\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
      <HintPath>..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Castle.Windsor, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
      <HintPath>..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
      <HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
      <HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="ImageResizer, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\ImageResizer.4.0.5\lib\net45\ImageResizer.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.AspNet.Identity.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.AspNet.Identity.EntityFramework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.Identity.EntityFramework.2.2.1\lib\net45\Microsoft.AspNet.Identity.EntityFramework.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.VisualStudio.CodeCoverage.Shim, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.CodeCoverage.1.0.3\lib\netstandard1.0\Microsoft.VisualStudio.CodeCoverage.Shim.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.VisualStudio.TestPlatform.14.0.0.1\lib\net20\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.VisualStudio.TestPlatform.14.0.0.1\lib\net20\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
      <HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
      <HintPath>..\packages\nunit.framework.2.63.0\lib\nunit.framework.dll</HintPath>
    </Reference>
    <Reference Include="Postal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=45719375b8b4d528, processorArchitecture=MSIL">
      <HintPath>..\packages\Postal.Mvc5.1.2.0\lib\net45\Postal.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="RazorEngine, Version=3.7.7.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a, processorArchitecture=MSIL">
      <HintPath>..\packages\RazorEngine.3.7.7\lib\net45\RazorEngine.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.ComponentModel.DataAnnotations" />
    <Reference Include="System.Core" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Web" />
    <Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="MyProjectReadService\AuthoriseToAdministerTests.cs" />
    <Compile Include="MyProjectReadService\MyProjectTests.cs" />
    <Compile Include="MyProjectReadService\CapabilityTests.cs" />
    <Compile Include="MyProjectReadService\CollectionTests.cs" />
    <Compile Include="MyProjectReadService\DiagnosisTests.cs" />
    <Compile Include="MyProjectReadService\LogoTests.cs" />
    <Compile Include="MyProjectReadService\MaterialPreservationDetailsTests.cs" />
    <Compile Include="MyProjectReadService\NetworkTests.cs" />
    <Compile Include="MyProjectReadService\OrganisationTypeTests.cs" />
    <Compile Include="MyProjectReadService\RegisterRequestTests.cs" />
    <Compile Include="MyProjectReadService\SampleSetTests.cs" />
    <Compile Include="MyProjectReadService\ServiceOfferingTests.cs" />
    <Compile Include="EmailServiceTests.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="SqlServerLogoStorageProviderTests.cs" />
    <Compile Include="WindsorInstaller.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="app.config" />
    <None Include="packages.config" />
    <None Include="Views\Emails\_ViewStart.cshtml" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\MyProject.Caching\MyProject.Caching.csproj">
      <Project>{ff0409c6-92bd-49d0-ba39-d3c63cb42c9c}</Project>
      <Name>MyProject.Caching</Name>
    </ProjectReference>
    <ProjectReference Include="..\MyProject.Data\MyProject.Data.csproj">
      <Project>{d029f30a-f65a-46b5-9e5d-d0b2251858d0}</Project>
      <Name>MyProject.Data</Name>
    </ProjectReference>
    <ProjectReference Include="..\MyProject.Identity.Contracts\MyProject.Identity.Contracts.csproj">
      <Project>{F24B10E2-0F6F-40ED-8CE4-0BD587D6827E}</Project>
      <Name>MyProject.Identity.Contracts</Name>
    </ProjectReference>
    <ProjectReference Include="..\MyProject.Search.Contracts\MyProject.Search.Contracts.csproj">
      <Project>{7121ef03-7230-4b37-af55-a3ee03ba41a0}</Project>
      <Name>MyProject.Search.Contracts</Name>
    </ProjectReference>
    <ProjectReference Include="..\MyProject.Services\MyProject.Services.csproj">
      <Project>{dc6a8e03-361c-4f85-8d31-5ba9c237c33e}</Project>
      <Name>MyProject.Services</Name>
    </ProjectReference>
    <ProjectReference Include="..\MyProject.TestUtils\MyProject.TestUtils.csproj">
      <Project>{0e050ea1-d815-492e-9b9b-7c69b4c6f2c0}</Project>
      <Name>MyProject.TestUtils</Name>
    </ProjectReference>
    <ProjectReference Include="..\MyProject.Utils\MyProject.Utils.csproj">
      <Project>{28432D0C-565A-4F39-8F41-B97BAE061186}</Project>
      <Name>MyProject.Utils</Name>
    </ProjectReference>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props'))" />
    <Error Condition="!Exists('..\packages\Microsoft.NET.Test.Sdk.15.6.0\build\net45\Microsoft.Net.Test.Sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NET.Test.Sdk.15.6.0\build\net45\Microsoft.Net.Test.Sdk.props'))" />
    <Error Condition="!Exists('..\packages\Microsoft.NET.Test.Sdk.15.6.0\build\net45\Microsoft.Net.Test.Sdk.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NET.Test.Sdk.15.6.0\build\net45\Microsoft.Net.Test.Sdk.targets'))" />
  </Target>
  <Import Project="..\packages\Microsoft.NET.Test.Sdk.15.6.0\build\net45\Microsoft.Net.Test.Sdk.targets" Condition="Exists('..\packages\Microsoft.NET.Test.Sdk.15.6.0\build\net45\Microsoft.Net.Test.Sdk.targets')" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

ReSharper / dotCover在单元测试会话/连续测试会话中提取254就好了。因此,如果我右键单击一个项目或解决方案并告诉它运行测试它运行正常,它们都通过了。可爱。

由于某些原因,Visual Studio对它们一无所知。如果我检查VS中的测试输出,我得到0结果:

[23/02/2018 22:54:40 Informational] ------ Discover test started ------
[23/02/2018 22:54:41 Informational] NUnit Adapter 3.9.0.0: Test discovery starting
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.Caching\bin\Debug\MyProjects.Caching.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.DataTests\bin\Debug\MyProjects.DataTests.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.Data\bin\Debug\MyProjects.Data.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.DTOTests\bin\Debug\MyProjects.DTOTests.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.ElasticSearch\bin\Debug\MyProjects.ElasticSearch.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.ExtensionsTests\bin\Debug\MyProjects.ExtensionsTests.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.Extensions\bin\Debug\MyProjects.Extensions.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.Identity.Contracts\bin\Debug\MyProjects.Identity.Contracts.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.Identity\bin\Debug\MyProjects.Identity.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.Search.Contracts\bin\Debug\MyProjects.Search.Contracts.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.Search.DTOs\bin\Debug\MyProjects.Search.DTOs.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.Services\bin\Debug\MyProjects.Services.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.ServiceTests\bin\Debug\MyProjects.ServiceTests.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.TestUtils\bin\Debug\MyProjects.TestUtils.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.UtilsTests\bin\Debug\MyProjects.UtilsTests.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.Utils\bin\Debug\MyProjects.Utils.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.ViewModelTests\bin\Debug\MyProjects.ViewModelTests.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\MyProjects.Web\bin\MyProjects.Web.dll
[23/02/2018 22:54:41 Informational] Assembly contains no NUnit 3.0 tests: C:\Users\Dummy\source\repos\MyProjects.initial\MyProjects\edmxbuilder\bin\Debug\edmxbuilder.exe
[23/02/2018 22:54:41 Informational] NUnit Adapter 3.9.0.0: Test discovery complete
[23/02/2018 22:54:41 Informational] ========== Discover test finished: 0 found (0:00:01.4894578) ==========

如果我让MS Hosted VS2017构建代理尝试在VSTS中运行测试,也会发生同样的情况。

我注意到的一件事是网上有人说在每个测试项目的bin / Debug目录中应该有一个nunittest.exe(或类似的),我的项目不会。

我已经禁用ReSharper尝试对此进行排序,但目前已打砖块。

2 个答案:

答案 0 :(得分:2)

您的项目文件表明您正在引用NUnit 2.6.3,这是NUnit V2的过时版本(甚至不是最后一个版本)。您无法在NUnit 3测试适配器下运行NUnit V2测试。相反,你需要NUnit测试适配器,我认为它现在达到2.0.1。

如果使用已安装的控制台运行程序运行,则测试应该成功运行。

如果您有(非常好)运行NUnit V2的原因,您至少应升级到2.6.4并安装NUnit(2)测试适配器。但是,理想情况下,您应该只需升级到最新版本的NUnit框架,该框架将在NUnit 3 VS测试适配器下正常运行。

答案 1 :(得分:0)

与@Charlie提到的有些相关。

原来我的.csproj引用了包nunit.framework v2.x。

这本身并不是一个问题(虽然我不推荐它),除非没有对NUnit v3.x包的引用,即使它位于packages.config中。

在我的情况下,这是因为我使用了ReSharper的建议,为测试.cs文件添加引用和使用语句来覆盖属性装饰器,例如[建立]。这有点狡猾,因为在NUnit 3中需要使用相同的using语句,因此.cs文件看起来应该完全正确。

恢复NuGet包不起作用,也没有卸载并重新安装包。

我最终做的是Update-Package -reinstall。这引起了各种混乱,但确实更新了我的.csproj和app.config。在团队资源管理器中完成所有其他更改,构建并运行测试,最终将它们拾起。

ReSharper很好但不完美。

相关问题