✅ Unit Testing in Rider not working
Hello, I've unsuccessfully attempted to use NUnit 3.14 with Net 8.0, and Xunit 2.5.3 with Net 8.0, and Xunit (2.0 or 2.1.0.3179) with Net 4.0, and NUnit 3.5 with Net 4.0 - all respectively shown in this video: https://www.youtube.com/watch?v=PyY5X7ylGOc
I've also tried both with Net 7.0
According to NUnit, Net 4.0 should be compatible with any NUnit underneath 4.3; I'm surprised NUnit 3.5 didn't work with Net 4.0: https://docs.nunit.org/articles/vs-test-adapter/Supported-Frameworks.html
Net 8.0 requires NUnit of at least 4.3.2; but Rider doesn't seem to have an option to use that version of NUnit, or to customize Xunit version; is it as simple as editing the version in the
.csproj
file?37 Replies
An error that shows up when I try to build a project with NUnit 3.5 and Net 4.0:
Error CS0246 : The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?)
referring to the line using NUnit.Framework;
I tried manually adding NUnit through cmd with dotnet add package NUnit --version 3.5.0.0
, but got Rider didn't like that: error: Error while adding package 'NUnit' to project 'E:\RiderProjects\FutileTest2\Test4\Test4.csproj'. The project does not support adding package references through the add package command.
Weird, I use Rider and have had no problems with either NUnit or XUnit. Can you perhaps reproduce and upload to github or similar?
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
Thanks for the responses.
I took the
3.5.0.0
from the default generated .csproj
file when Net 4.0 was selected, not sure what it means- it's at 3:00
in the video I posted.
Now using Net 8-
dotnet add package NUnit
for me within the project folder returns:
dotnet new nunit -n new_project
when used from my solution folder with a non-existing project name returns:
Sure, I reproduced using Net 8, and 3 projects, a default console project, an NUnit default project, and an XUnit default project - https://github.com/wood73/PlzUnitTest
Thanks for taking a look.
GitHub
GitHub - wood73/PlzUnitTest: An attempt at using NUnit and XUnit wi...
An attempt at using NUnit and XUnit with Net 8 using the IDE Rider - wood73/PlzUnitTest
I also tried a 2023 version of Rider to no avail (I used the latest version for the tests above)
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
I'll try anything :b
I created that file in my solution folder and rebuilding + reloading my projects, I didn't observe changes.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
hm, the versions used in your xunit project are... weird
is what I would expect
but yeah something seems to be wrong with your nuget, based on those errors
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
I got it working! Thank you both- I had to remove Nuget from my system/user path variables
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
I think I downloaded Nuget before the issue happened, and manually added it into my windows path/environment variable, so I'm guessing that Rider was mistakenly using the wrong version of Nuget somehow or caused some issue I don't understand.
I'm re-adding it to my path/environment system variable to recreate the issue, and restarting Rider- weird, it still works, maybe that wasn't the issue.
Here's what I did before it was solved:
1. remove nuget from both path variables
2. (probably incorrect step): remove dotnet from both path variables
3. use command:
dotnet add package NUnit
from CMD, inside an NUnit project (the CMD might've been opened before removing dotnet from path, hence why the dotnet command worked)
Then it was solved even inside newly created Solutions.
I've been re-installing Rider a few times, maybe if I re-install Rider when Nuget is set in my environment variables it'll recreate the issue.
I don't know.Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
yes
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
ah
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
no I just removed then re-added dotnet, it's possible that the dotnet it was pointing to was different before and after changing it, but I doubt it
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
I'm on windows. Idk if it was different before but now it's pointing here
sure
dotnet --info
returns:
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
ok haha
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
I'll try looking for a separate install location
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
It might've been pointing to visual studio's dotnet - I actually deleted Visual studio 2017 and Visual studio 2019 at some point.
Found 'em, deleted 7.0
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
got this for 4.5 so I kept it installed
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
whoops
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
I don't think so, but I've programmed in C for cuda, and Java before, so I'm not sure if something else was wrong
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
yea