After struggling to create a unit test project using NUNIT, I came to the page https://docs.microsoft.com/en-us/visualstudio/test/getting-started-with-unit-testing?toc=%2Fvisualstudio%2Fget-started%2Fcsharp%2Ftoc.json&bc=%2Fvisualstudio%2Fget-started%2Fcsharp%2Fbreadcrumb%2Ftoc.json&view=vs-2019&tabs=mstest and followed the exact steps, which in my past experience of these guides will work. However did not find any tests, it simply does not "locate" or detect any tests, and there are not clues as to why.
Visual Studio 2019 community edition, i installed it a few days ago only.
TargetFramework>netcoreapp3.1
...
PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
PackageReference Include="coverlet.collector" Version="1.3.0" />
...
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@zaphodikus -- Conrad, thank you for your feedback. Please consider these resources, and let me know your results:
@zaphodikus Conrad, were you able to see the NUnit template, and you used the NUnit template to create the unit tests? What VS workloads do you have installed? @kendrahavens @AbhitejJohn in case they have some ideas on this.
@zaphodikus : I'd recommend using the nunit template as Mike pointed out. You'd want to make sure that the project has a reference to the nunit test adapter as well, which is a separate package from the framework. The template takes care of all of this for you. Also, most troubleshooting information is put out in the Output->Tests pane and verbosity can be toggled from the the top level menu, Test->Options. Please let us know if that's useful.
I found the root cause at least of the general troubles with NUnit and Core. I have installed VS2019 community to D: , It's D: I made the default location for applications to d: Installing Studio to C: did not resolve, but setting an environment variable
DOTNET_ROOT=D:\Program Files\dotnet\
Sorted it out when I finally focused on the Test output window by pressing CTRL+ALT+O , I had been struggling to correctly recall and press that combination. The console output window was not opening/visible for some reason, and I had not managed to get the test console output, because that then troubleshooted very easily from there.
I had used a few avenues up and posted elsewhere the problem because the example project did work fine in the official Microsoft development VM, (which is a brilliant resource) as did my own project, So I knew it had to be my environment, which had almost every single path rooted as D:\ Hope this helps the next person.
@zaphodikus : Glad you got that working. Looks like that is the recommendation from here: https://github.com/dotnet/sdk/issues/12359
So, sounds like the issue is .NET Core and not much to do with NUnit, and there's no doc update here. Sound right?
@Mikejo5000 That's correct.
Thanks!