Help with sorting package issues in Visual Studio.
I am trying to follow the walkthrough for Test-driven development using Test Explorer here: https://learn.microsoft.com/en-us/visualstudio/test/quick-start-test-driven-development-with-test-explorer?view=vs-2022#create-a-test-and-generate-code
The problem I have is that the TestClass references that are supposed to be highlighted after creating the MSTest project template aren't there (see image1).
This seems to be because it cannot find the up to date dependencies (see image 2).
I tried going to Tools>NuGet Package Manager>Manage NuGet Packages for Solution, and am confused as I can see that the correct packages and versions are in the "Installed" tab, but labelled as "Not available in this source" (see image3)
How can I fix this issue?
Many thanks.
Test-driven development walkthrough - Visual Studio (Windows)
Learn how to develop a tested method in C# using Microsoft Test Framework, which you can easily adapt for other languages or test frameworks, such as NUnit.
7 Replies
Hm. Can't really say, but I would highly recommend using XUnit instead of MSTest these days
everything else will be roughly the same, its just slightly less attributes
im just looking to follow the tutorial in the post
i fixed this issue myself by adding https://api.nuget.org/v3/index.json to the nuget package sources and installing via there
and then running build and swapping back to the local package source
ah, thats the default source, dunno why it wasnt already in
yeah not sure either, the walkthrough didnt mention it but at least now i have some underestanding of nuget package manager that i didnt befoe
great! did you get your unittests working?
yep, all working fine. ive swapped to NUnit in a different project now that ive got it woking
but tbh the main idea was to do a bit of TDD as I need to use it in an upcoming interview
and ive never used Visual Studio before, only VScode
nunit (and Xunit, the even better choice) also have great integration with VS
so you're not forced to use mstest, and I would indeed recommend not using it
xunit has ~50% of the market, nunit ~40%, and mstest the last 10%