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

.nunit project file with nunit3-console.exe and .net 8.0? #1512

Open
Clumi opened this issue Mar 21, 2024 · 8 comments
Open

.nunit project file with nunit3-console.exe and .net 8.0? #1512

Clumi opened this issue Mar 21, 2024 · 8 comments
Labels
Investigate We are looking into the issue

Comments

@Clumi
Copy link

Clumi commented Mar 21, 2024

I have a very old project that still runs NUnit 2. I'm trying to update it to NUnit 4. I downloaded the NUnit.Console-3.17.0 zip and added the nunit-extension-nunit-v2-driver.3.9.0 dll's manually. Then I tried to run the NUnit 2 .unit file with the nunit3-console.exe in the net8.0 folder of the console download. However, this fails with "File type is not supported". I checked the loaded dll's and the list looks fine, specifically it includes the IProjectLoader interface:

.\nunit3-console.exe --list-extensions
NUnit Console 3.17.0+685c5b542b5e9ba632c905f0bd514a773d9758af (Release)
Copyright (c) 2022 Charlie Poole, Rob Prouse
Thursday, 21 March 2024 12:06:27

Runtime Environment
   OS Version: Microsoft Windows 10.0.19045
  Runtime: .NET 8.0.1

Installed Extensions
  Extension Point: /NUnit/Engine/NUnitV2Driver
  Extension Point: /NUnit/Engine/TypeExtensions/IService
  Extension Point: /NUnit/Engine/TypeExtensions/ITestEventListener
  Extension Point: /NUnit/Engine/TypeExtensions/IDriverFactory
  Extension Point: /NUnit/Engine/TypeExtensions/IProjectLoader
  Extension Point: /NUnit/Engine/TypeExtensions/IResultWriter

I then tried to run the same file with the console runner in the net35 folder, and it could read the project file just fine. Is it not possible to use the modern versions of dotnet with a .nunit file or am I doing something wrong?

@OsirisTerje
Copy link
Member

OsirisTerje commented Mar 21, 2024

That's a good question. I can't remember that we have deprecated it, so yes, it should work. However, not many uses this anymore, and I can't remember either if we have any tests to verify it works - so it might have been inadvertently "killed".

Could you create a small repro project and a script file to run it the way you do manually? Then we can try to check what is causing this.

However, if you're stepping up to NUnit 4 it might make sense anyway to move off the this and over to using dotnet test instead.

SOME MORE:

If you update the framework from NUnit 2 to NUnit 4, you should not need the NUnitV2Driver.

@OsirisTerje OsirisTerje added the Investigate We are looking into the issue label Mar 21, 2024
@Clumi
Copy link
Author

Clumi commented Mar 21, 2024

I'm using the NUnitV2Driver so I can keep the tests running while updating them all to a more recent framework version. This will take me a while.

I created a small test project here: https://github.com/Clumi/nunit-test/tree/main
There are two powershell scripts for each of the variants I described at the top.

Thank you for your time and help!

@mikkelbu
Copy link
Member

@Clumi You need to install the "NUnit Project Loader" - https://docs.nunit.org/articles/nunit-engine/extensions/AvailableExtensions.html#nunit-project-loader - to run .nunit files

@Clumi
Copy link
Author

Clumi commented Mar 22, 2024

@Clumi You need to install the "NUnit Project Loader" - https://docs.nunit.org/articles/nunit-engine/extensions/AvailableExtensions.html#nunit-project-loader - to run .nunit files

The console zip comes with most add-ons preinstalled - I also manually added the dll to the 8.0 folder to be sure as you can see in the repo I uploaded:
https://github.com/Clumi/nunit-test/blob/main/NUnit.Console-3.17.0/bin/net8.0/nunit-project-loader.dll
Sadly, this didn't lead to .nunit-files being useable. Are there any further steps I missed?

@OsirisTerje
Copy link
Member

@Clumi Can you check this with the 3.18.1 release of the console ?

@Clumi
Copy link
Author

Clumi commented Sep 3, 2024

I just checked with the newest Console Release (3.18.1). Unfortunately it does not include a Dotnet Framework 3.5 console, so I could only test it with versions 4.6, 6 and 8. Versions 6 and 8 fail with "File type is not supported", but 4.6 is able to read the .nunit file. This is great news, since it means I can now upgrade our NUnit. Thank you a lot!

@stevenaw
Copy link
Member

stevenaw commented Nov 7, 2024

I'm unsure if this is more of a console issue or the project loader, but I'm going to transfer it to the console runner repo as it sounds like it may be unable to load the plug-in.

@stevenaw stevenaw transferred this issue from nunit/nunit Nov 7, 2024
@CharliePoole
Copy link
Member

Let's deal with your initial problem first. The runner in the net8.0 directory is known as the NUnit NetCore Console Runner and it only runs tests under .NET Core. It won't run tests under any version of the .NET Framework.

When you run from the net35 directory (or net462 in later versions) you are running what amounts to an entirely different program, which I have started to call the Standard runner. It's unfortunate that the executables for both of these have the same name, but we're stuck with that until there is a new major version. NOTE: I say it's a different program because we use conditional compilation that gives the two programs entirely different features.

When you run the Standard runner (net35 or net462) your tests actually run in a separate process by default. The latest production release (3.18.3) is using a .NET 8.0 agent to run your tests, so no, you are not stuck using old runtimes. :-)

The V2 Framework Driver extension is another matter. NUnit V2 didn't support anything but the .NET Framework, since that's all that existed at the time. So, if you are running NUnit V2 tests, then you have to run under .NET Framework, although it can be a newer version. OTOH, once you upgrade to NUnit 3 or 4 (IMO 2 to 4 is a rather big jump and not one I would do in one step) you no longer need the V2 framework driver. For that reason, it's not one of the extensions that will eventually become multi-targeted.

Regarding the NUnit Project loader... copying an extension file to the bin directory is not the way to install them. They must be installed correctly using nuget.exe or an equivalent approach. However, it sounds as if your resolved this problem.

@Clumi Reading through this, I can't see anything left to fix, so I'd like to close it, but I'll wait for your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate We are looking into the issue
Projects
None yet
Development

No branches or pull requests

5 participants