簡體   English   中英

NUnit測試可以在ReSharper(“單元測試會話”窗口)中運行,但是Visual Studio和Hosted VSTS構建代理找不到任何測試

[英]NUnit tests work in ReSharper (Unit Testing Session window), but Visual Studio, and Hosted VSTS build agent don't find any tests

我剛剛拿起一個舊的(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嘗試對其進行解決,但目前遇到了障礙。

您的項目文件表明您正在引用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測試適配器下正常運行。

與@Charlie提到的內容有關。

原來我的.csproj引用了軟件包nunit.frameworkv2.x。

除了沒有引用NUnit v3.x軟件包,即使它在packages.config中,這本身也不是問題(盡管我不推薦)。

在我的情況下,這是因為我使用了ReSharper的建議來添加參考,並在測試.cs文件中使用語句來覆蓋屬性修飾符,例如[SetUp]。 這有點狡猾,因為在NUnit 3中,需要使用相同的using語句,因此.cs文件看起來應與實際情況完全相同。

恢復NuGet軟件包無效,也無法卸載並重新安裝該軟件包。

我最終要做的是Update-Package -reinstall 這引起了各種各樣的混亂,但是確實更新了我的.csproj和app.config。 取消Team Explorer中的所有其他更改,構建並運行測試,最終將其選中。

ReSharper很好,但並不完美。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM