✅ Unit tests not appearing
Hello! For once I'm doing a little project in the console rather than in Unity, meaning for unit tests I'm having to add the package myself. I've added the NuGet packages NUnit and NUnit.Console, and I've written a test file that doesn't give any complains. When I try add run it though, the Unit Test tab of Rider show's no tests. I can't figure out why though.
All I can think of is the assembly not being referenced, but Rider says it does that automatically for NUnit packages. Any ideas? I'm sure it's something simple didn't know was a step.
Here's the test class, in case I've done something wrong there.
7 Replies
If you go to that folder on the command line (in PowerShell for instance) and run
dotnet test
does it work?All it gave me was
Try that
If it works, compare the generated csproj with the one you have that isn't working.
Just making sure, since I saw two separate tutorials showing doing this with the project initially made as a unit testing project, it's not a problem adding in the packages afterwards, no? I'm adding these tests in part way through now I can see this project is big enough to need them.
That works, yes.
Got it. I needed Microsoft.NET.Test.Sdk. Thank you. Really doubt I'd have figured that out any time soon.
I think using one of the templates via
dotnet new
or using Visual Studio is always a good idea when you are bootstrapping a new project.Sounds sensible. Really hadn't planned for this project to become so complicated though 😅 Guess that's how it always goes.