Running nUnit tests for .NET Core in Rider
Asked Answered
K

1

9

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.

Keitt answered 13/12, 2017 at 15:10 Comment(0)
K
11

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
  • NUnit3TestAdapter
  • Microsoft.Net.Test.SDK
  1. Reference your the .NET Core project you want to test in the dependencies

  2. Start testing using NUnit.Framework;

Keitt answered 13/12, 2017 at 18:35 Comment(1)
In Rider there's no need to unload project before editing csproj. Just focus project in Solution Explorer and press F4.Hostess

© 2022 - 2024 — McMap. All rights reserved.