Reputation: 984
After updating VS Pro 2022 to the newest available version 17.4.0, I am no longer able to run any NUnit tests in one of my VS solutions. The test explorer correcly displays the list of tests, however, none of them are actually executing. I can see that some warnings are accumulating, here's the printout:
========== Starting test discovery ==========
Test project TestHelpers does not reference any .NET NuGet adapter. Test
discovery or execution might not work for this project.
It's recommended to reference NuGet test adapters in each test project in the solution.
Test project TestHelper.NUnitAssert does not reference any .NET NuGet
adapter. Test discovery or execution might not work for this project.
It's recommended to reference NuGet test adapters in each test project in the solution.
Test project TestHelper.AutoData does not reference any .NET NuGet adapter.
Test discovery or execution might not work for this project.
It's recommended to reference NuGet test adapters in each test project in the solution.
Test project TestHelpers.Data does not reference any .NET NuGet adapter.
Test discovery or execution might not work for this project.
It's recommended to reference NuGet test adapters in each test project in the solution.
NUnit Adapter 4.2.0.0: Test discovery starting
NUnit Adapter 4.2.0.0: Test discovery starting
NUnit Adapter 4.2.0.0: Test discovery starting
NUnit Adapter 4.2.0.0: Test discovery starting
NUnit Adapter 4.2.0.0: Test discovery starting
Exception System.TypeInitializationException, Exception thrown discovering tests in C:\Projects\MyProj\TestProjects\TestHelpers\bin\Debug\TestHelpers.dll
The type initializer for 'NUnit.Engine.Services.RuntimeFrameworkService' threw an exception.
NUnit Adapter 4.2.0.0: Test discovery starting
at NUnit.Engine.Services.RuntimeFrameworkService.ApplyImageData(TestPackage package)
at NUnit.Engine.Services.RuntimeFrameworkService.SelectRuntimeFramework(TestPackage package)
at NUnit.Engine.Runners.MasterTestRunner.GetEngineRunner()
at NUnit.Engine.Runners.MasterTestRunner.Explore(TestFilter filter)
at NUnit.VisualStudio.TestAdapter.NUnitEngine.NUnitEngineAdapter.Explore(TestFilter filter) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEngine\NUnitEngineAdapter.cs:line 88
at NUnit.VisualStudio.TestAdapter.NUnit3TestDiscoverer.DiscoverTests(IEnumerable`1 sources, IDiscoveryContext discoveryContext, IMessageLogger messageLogger, ITestCaseDiscoverySink discoverySink) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestDiscoverer.cs:line 82
InnerException: System.ArgumentException: Unknown framework version 7.0
Parameter name: version
at NUnit.Engine.RuntimeFramework.GetClrVersionForFramework(Version frameworkVersion)
at NUnit.Engine.RuntimeFramework..ctor(RuntimeType runtime, Version version, String profile)
at NUnit.Engine.RuntimeFramework.GetNetCoreRuntimesFromDirectoryNames(IEnumerable`1 dirNames)
at NUnit.Engine.RuntimeFramework.FindDotNetCoreFrameworks()
at NUnit.Engine.RuntimeFramework.get_AvailableFrameworks()
at NUnit.Engine.Services.RuntimeFrameworkService..cctor()
NUnit Adapter 4.2.0.0: Test discovery complete
Rolling back to previously used version 17.3.6 seems to fix the issue.
Perhaps anyone encountered a similar issue?
Upvotes: 15
Views: 14394
Reputation: 358
In doing the upgrade, NuGet Package manager complained that "Nunit.Console Runner 3.15.2 failed to uninstall. Restart Visual Studio to finish the process"
Restarted it several times but the error persisted and Nunit tests wouldn't run.
I removed nunit.framework reference from the Nunit test project, then added it back it. Afterwards the tests successfully ran.
I hadn't run tests since last commit yesterday evening and started to make changes this morning - thought it was something I'd done !
Phew !
Upvotes: 1
Reputation: 984
Managed to resolve the issue by upgrading NUnit3TestAdapter to version 4.3.0 as per recomendations in here: https://github.com/nunit/nunit3-vs-adapter/issues/987
Also, had to add NUnit3TestAdapter nuget to the four TestHelpers projects which are mentioned in the log.
Upvotes: 24