Checking that we have added test adapter for NUnit so that our tests in Azure Devops are run
A challenge with running tests inside Powershell can be if NUnit test adapter Nuget package is missing from the solution.
If you run test using NUnit 2.x, you require NUnitTestAdapter. If you use NUnit 3.x, NUnit3TestAdapter is required.
The following Powershell script can be used to check if we have added a Nuget package reference at least to one such test project in the
solution. We have here some tests that will list up all PackageReference in csproj files of the solution.
Note: this requires the following setup of your Nuget package references listed in the solution.
You have to have csproj projects in the solution
You must use PackageReference, i.e. list up nuget packages in the csproj file. This will not work if you instead use packages lock json format or packages.config.
For example, we could run the function call :
List-PackagesOfTestProjectInSolution "C:\dev\someacme\someacme.sln"
And we get our lists of package references in that solution (here we only look inside projects with a name containing "Test":