Unit tests don't work with NUnit
Answered
Hello,
I have a project with some NUnit tests in. I am using Build #RS-163.3419, built on August 27, 2016 with NUnit 3.4.1. My test class looks something like this:
using NUnit.Framework;
using Shouldly;
namespace BurglarAlarm.Tests
{
[TestFixture]
public class AlarmTests
{
[Test]
public void TestDoorContactButtonPress()
{
const string str = "AE594AEDFCC0";
var sut = new BurglarMessageDecoder();
var output = sut.GetEventFromHexString(str);
output.Device.ShouldBe(DeviceType.DoorContact);
output.Trigger.ShouldBe(TriggerType.Button);
output.MacAddress.ShouldBe(0xae594a);
}
}
}
No gutter icons appear next to my test and the unit test explorer window shows "None" tests. Here is my project.json file:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Autofac": {
"type": "build",
"version": "4.1.0"
},
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-*"
},
"NUnit": "3.4.1",
"Shouldly": "2.8.2",
"dotnet-test-nunit": "3.4.0-beta-2"
},
"testRunner": "nunit",
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
What am I doing wrong? The tests work with "dotnet test".
(Image showing missing gutter icons)
(Image showing unit test runner)
Please sign in to leave a comment.
Rider (and ReSharper) don't currently support asp.net testing. It's coming in the ReSharper 2016.3 timeframe.
@Matt I'm not using ASP.Net. Are you saying .NET Core testing is unsupported?
Ah, no, that was a typo. Meant to say .net core testing. It's not in the current build, but should be there in the next build.
Is this still planned to come in the next release? As it stands right now, I would like to be able to debug my xunit tests, and machine.spec tests. I am forced to use dotnet test to retest everything, and writing to console for everything i'm interested in watching when finding problems
Yes, .net core testing support is still coming. It will support nunit and xunit, but not mspec until plugins are implemented.
Was NUnit (w/ .NET Core) testing supposed to work with the latest EAP (released 22nd, v163.6834)?
Not yet, I'm afraid. We need to make it all run correctly cross platform, and it's still on a branch, not in the build. We're still working on it - it will get there!
How about now? Build #RS-171.4456.575, built on June 16, 2017 is supposed to have NUnit support, but this is not being discovered for my project.
Running `dotnet test` works as expected and the tests can even be run and debugged in VS Code... am I missing something?
@Stephan does Rider template project work fine? Please share more details about your project and environment (os, dotnet version). Thanks!
Hi @Ivan
Your answer led me to check a few more things, and in fact here is what I found:
I have tested this across the board, i.e. Windows / Linux / MacOS
Is this by design? I have not found any documentation supporting it.
I am running dotnet 1.1.0 with 1.0.4 SDK
@Stefan,
According to our information if tests project targets netstandard1.6, then no tests are run via dotnet test / Re# / Rider.
I will do more testing on Monday and follow up. Thanks!
I am in fact targeting netcoreapp1.1 which in turn targets netstandard1.6.
In the meantime I've converted my unit tests to xUnit, yet I am 100% certain that the NUnit tests ran successfully via dotnet test
Thank you for looking into this.
I have the same Error using Nunit Test adapter version 3.8.0 Alpha 1, with last build of Rider, in PowerShell "dotnet test" works fine and using VS2017 works fine too, but Rider still not seeing any tests in my project, the target framework is netcoreapp1.1
I have reproduced the problem in Rider, however the fix will not get into upcoming Rider release.
It was already fixed in the recent ReSharper EAP (check comments here https://youtrack.jetbrains.com/issue/RSRP-464912#comment=27-2312509), but backporting to Rider is not feasible at this point, sorry. I am sure it will not take much time after release to start next iteration of Rider EAPs, which will get the fix from ReSharper.
BTW Rider has a very nice Terminal, for running dotnet test and other console apps
:) Thank you Ivan... and yes, believe me, I'm an avid terminal user... it's lovely.
Keep up the good work on Rider... is there anywhere where we can follow what's being worked on and what's in the pipeline?
Thanks for understanding. We use youtrack to plan must fix list issues for next_eap / release, but this grouping information is not accessible outside.
This is far from ideal... is the problem fixed yet? I am using rider and I'm surprised to see that it's not discovering .NET Core tests.
Hi Kiran
I don't know the state of NUnit on .NET Core, I've since switched to xUnit, which I'm actually starting to believe is better for me than NUnit. That said, xUnit tests and discovery works fine on the latest version as of writing.
@Kiran net core nunit will be available in 2017.2 EAP, in the very first build, when it starts.
@Ivan That's great news. Do you have a date for this? Also do you have a list of proposed features for the early access program?
@Info
Hopefully, end of this week, according to this tweet
https://twitter.com/JetBrainsRider/status/897793219567771648
@Stefan Camilleri, I've also been having problems with test discovery for xunit using dotnetcore on a Mac? I will check again this evening.
@Ivan You guys are awesome!
@Info - I am also on a mac, and this is working fine currently on the current beta with a little hack that I discovered and documented here -> https://youtrack.jetbrains.com/issue/RIDER-7886
I'm unsure if this still affects the current version, since my system is patched (I'm on macOS High Sierra beta 6)... but give it a go.
Wow that took a bit of fiddling around but it now works! Thanks!
Glad it helped @Kiran
Hi,
was the version released? I test with the latest version and don't show Nunit test in rider.
Hi,
was the version released? I test with the latest version and don't show Nunit test in rider with netcore
@Gisela, it was. https://blog.jetbrains.com/dotnet/2017/10/12/jetbrains-rider-2017-2-released/
What is your OS, Rider version, it mayy help if you attach Rider logs from Help-Show log in Finder.
Thanks!