Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running nUnit tests for .NET Core in Rider

It might be a simple question, but it seems I can't figure out how to combine NUnit and a .NET Core project in Rider.

It is nowhere in the templates and if I just create a simple class library and reference a NuGet package I guess that is not the option. None of the usual NUnit items are recognized even if I reference using NUnit.Framework just like it is referenced in the usual .NET.

Either I don't know something or it is not yet supported. Has anyone had any experience in using NUnit with .NET Core in JetBrains' Rider IDE?

I know there is MSTest and xUnit available, but I am really used to NUnit, so I really want to make sure there isn't any workaround.

like image 333
Yuri Zolotarev Avatar asked Dec 13 '17 15:12

Yuri Zolotarev


1 Answers

So here is how I did it thanks to the article .NET Standard and .NET Core unit tests not discovered with new .csproj format in Visual Studio 2017 .

  1. Create an empty .NET Core Class Library

  2. Unload the project

  3. Edit the .csproj file. For some reason it points to target netstandard2.0. Set it to point to netcoreapp2.0.

  4. Download NuGet Packages

    • NUnit 3.9.0
    • nUnit3TetAdapter
    • Microsoft.Net.Test.SDK
  5. Reference your the .NET Core project you want to test in the dependencies

  6. Start testing using NUnit.Framework;

like image 70
Yuri Zolotarev Avatar answered Oct 13 '22 04:10

Yuri Zolotarev