18

I am trying to run NUnit tests for a .NET Core 2.0 project in Visual Studio 2017 through ReSharper. I've had the test .proj assembly set both as console application and class library. So it doesn't seem to be the output type. The solution does not discover any unit test and just displays no results with 0 tests run.

Here is my .csproj file for the tests project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <AssemblyName>eCorp.WebStore.OrderService.Tests</AssemblyName>
    <RootNamespace>eCorp.WebStore.OrderService.Tests</RootNamespace>
    <ApplicationIcon />
    <OutputType>Exe</OutputType>
    <StartupObject />
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
    <PackageReference Include="NUnit" Version="3.9.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\Core\OrderService.Domain\OrderService.Domain.csproj" />
    <ProjectReference Include="..\..\Core\OrderService.Infrastructure\OrderService.Infrastructure.csproj" />
  </ItemGroup>

</Project>

I found this already: Run NUnit tests in .NET Core

None of the provided solutions seem to work for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
qubits
  • 1,227
  • 3
  • 20
  • 50
  • I'd consider changing your accepted answer to D.G.'s. The current accepted answer (not possible) perhaps _was_ correct, but now it all works like a charm with the correct packages installed. – Todd Menier Mar 20 '18 at 19:20
  • @ToddMenier also need ReSharper running >2018.X (Updating mine to 2018.2.3 fixed the issue) – Byron Ross Nov 08 '18 at 23:41

3 Answers3

36

I solved by installing the following NuGet packages

  • NUnit
  • NUnit3TestAdapter
  • Microsoft.NET.Test.Sdk
Richard Ev
  • 52,939
  • 59
  • 191
  • 278
DavideGalifi
  • 676
  • 7
  • 7
3

ReSharper is known to have problems running .NET Core 2.0 tests in Visual Studio 2017. Try to run them without ReSharper.

For more information see this Stack Overflow question and answers: .NET Core 2.0 and xUnit doesn't run.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jacek Blaszczynski
  • 3,183
  • 14
  • 25
3

If you've installed the packages in D.G's answer and it still doesn't work, check if you need to update ReSharper. That worked for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mdickin
  • 2,365
  • 21
  • 27