Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade NUnit3TestAdapter to fix "Unknown framework version 7.0" #3302

Merged
merged 3 commits into from
May 15, 2023

Conversation

fredericDelaporte
Copy link
Member

I can no more run tests in the 5.4.x branch due to some error in the NUnit discovery engine when having dotnet 7.0 installed. (I do not have the issue in the 5.3.x branch, likely because it uses an old enough NUnit version, but I have not checked that was the actual reason.)

Upgrading it fixes the issue.

@hazzik
Copy link
Member

hazzik commented May 9, 2023

According to this need to upgrade only nunit-console 3.15.4 or 3.16.0 nunit/nunit3-vs-adapter#1090 (comment)

@hazzik
Copy link
Member

hazzik commented May 9, 2023

@fredericDelaporte how do you run tests? I have .NET 7 installed and don't seem to have a problem.

PS C:\Projects\nhibernate-core> dotnet --list-sdks
6.0.408 [C:\Program Files\dotnet\sdk]
7.0.203 [C:\Program Files\dotnet\sdk]

I tried from ShowBuildMenu.bat option C -- works fine on both 5.4.x and master branches

@fredericDelaporte
Copy link
Member Author

fredericDelaporte commented May 10, 2023

That is running inside Visual Studio (not Code) that does fail. I use the test explorer to run only the test I am interested in. I have seen the trouble with Visual Studio Community 2022 edition, 17.5.5. (Maybe the last time I have done that, but on 5.3.x, I was using my professional laptop with a VS2022 Professional.)

@fredericDelaporte
Copy link
Member Author

fredericDelaporte commented May 11, 2023

Downgrading the engine to .2 version dodges the bug we have in our SetSnapShot utility and still allows me to test in VS 2022. (Professional, currently I am on my professional laptop without access to my personal one. I do repro the trouble on VS 2022 Professional when attempting to test from a cleaned-up solution reloaded in a freshly opened VS, before the NUnit test adapter upgrade.)

For reference, here is the test output in VS when failing to launch tests:

NUnit Adapter 4.2.0.0: Test discovery starting
Exception System.TypeInitializationException, Exception thrown discovering tests in D:\OpenSource\nhibernate-core\src\NHibernate\bin\Debug\net461\NHibernate.dll
The type initializer for 'NUnit.Engine.Services.RuntimeFrameworkService' threw an exception.
   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
No test is available in D:\OpenSource\nhibernate-core\src\NHibernate\bin\Debug\net461\NHibernate.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

With the upgraded test adapter, no trouble and output is:

NUnit Adapter 4.4.0.0: Test discovery starting
NUnit Adapter 4.4.0.0: Test discovery complete

@hazzik
Copy link
Member

hazzik commented May 15, 2023

Turns out I have the same issue in Rider.

@hazzik
Copy link
Member

hazzik commented May 15, 2023

Updating the test adapter to 4.3.0 fixes the issue for me.

@hazzik hazzik changed the title Upgrade NUnit to fix unkown framework 7.0 Upgrade NUnit3TestAdapter to fix "Unknown framework version 7.0" May 15, 2023
@fredericDelaporte fredericDelaporte merged commit 170210a into nhibernate:5.4.x May 15, 2023
7 checks passed
@fredericDelaporte fredericDelaporte deleted the upgrade-nunit branch May 15, 2023 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants