Matt Styles
Matt Styles

Reputation: 611

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

I've just picked up an old (ish) project, which had a load of unit tests commented out. I want to revive the tests, and increase the code coverage so we can crack on with TDD.

I'm running VS2017 (15.5.7), ReSharper 2017.3.2, dotCober 2017.3.2 - all the latest versions. The project is Framework v4.7.1 (upgraded from 4.5.2). I've got the NUnit3 Test Runner Extension installed in VS.

It's a clean Windows installation so no old gunk left on it.

An example 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>

This is after I upgraded all the packages to the latest version.

The .csproj to go with it is:

<?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 pick up 254 just fine in the Unit Testing Session/Continuous Testing Session. So if I right-click a project or solution and tell it to run tests it runs them fine, and they all pass. Lovely.

For some reason Visual Studio has no idea about them. If I check the Tests output in VS, I get 0 results:

[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) ==========

The same happens if I Get the MS Hosted VS2017 build agent to try running the tests in VSTS.

One thing I did notice is that some people online say there should be an nunittest.exe (or similar) in each test project's bin/Debug directory, which my projects don't.

I've disabled ReSharper to try and sort this out but currently hit a brick wall.

Upvotes: 0

Views: 626

Answers (2)

Matt Styles
Matt Styles

Reputation: 611

Somewhat related to what @Charlie mentioned.

Turns out my .csproj had a reference to package nunit.framework v2.x.

This in itself isn't an issue (though I wouldn't recommend it) except there were no references to package NUnit v3.x, even though it was in the packages.config.

In my case this was because I had used ReSharper's suggestion for adding a reference and using statement to the tests .cs file to cover the attribute decorators e.g. [SetUp]. This is a bit sly to spot because in NUnit 3 the same using statement is needed so the .cs file looks exactly as it should be.

Restoring NuGet packages didn't work nor did uninstalling and reinstalling the package.

What I ended up doing is Update-Package -reinstall. This caused all sorts of chaos but did update my .csproj and app.config. Undid all the other changes in Team Explorer, built, and ran tests and it finally picked them up.

ReSharper is good but not perfect.

Upvotes: 0

Charlie
Charlie

Reputation: 13726

Your project file indicates you are referencing NUnit 2.6.3, an outdated version (and not even the last version) of NUnit V2. You can't run you NUnit V2 tests under the NUnit 3 Test Adapter. Instead you need the NUnit Test Adapter, which I believe is up to 2.0.1 now.

If you run using the console runner you have installed, the tests should run successfully.

If you have a (very good) reason for running NUnit V2, you should at least upgrade to 2.6.4 and install the NUnit (2) test adapter. Ideally, however, you should simply upgrade to the latest version of the NUnit framework, which will run fine under the NUnit 3 VS Test Adapter.

Upvotes: 2

Related Questions