-
Notifications
You must be signed in to change notification settings - Fork 152
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
Simplify locating of addins #488
Comments
You can currently do this by either modifying the delivered addins file or (better) adding a new one pointing to that directory. That may not totally do the job for you but if you try it I think we'll learn better what us needed. |
Where is your console coming from at the moment? If you install both console and addins by NuGet, the engine should find the addins automatically already. |
Imaging nunit-console came from unknown location, for instance it's pre-installed on build machine (appveyour, etc). And I do nunit3-console /full/path/to/my/tests.dll Actually I don't know where Generally if you explore some example of the extension https://github.com/reportportal/agent-net-nunit/blob/master/README.md, you might see that the hardest part of the installation is to say This issue is about the following case:
|
It's probably the biggest issue with extensions that there's no easy way to install them manually. If you use either nuget or (my favorite) chocolatey, they are all findable very easily. But if you copy artifacts, you are basically down to a manual process, which is easy to get wrong. As you can see from the docs, the process of locating extensions starts wherever the nunit.engine.dll is located. If it is located in your project, because you installed via nuget.org, then any extensions that are also installed by nuget.org are found automatically. When I use chocolatey to install a copy of the console runner centrally, then the starting point is inside a chocolatey directory. Extensions that are also installed via chocolatey are found, but no others. When the msi is installed centrally, there is no way to add new extensions except to add new addin files in the the engine directory. This overall separation of different install methods is actually by design. If you install the engine in your project, it should not be picking up extensions from some central location. However, IMO at least, it would make sense to do as you are asking and have the central installs also look into the project that is being executed for extensions. |
Hey @nvborisenko - you've raised a good point. I agree that in your situation there should be an easier way to install extensions. I'm less convinced that searching the test directory for them is the right solution. As far as I can see, there's a few drawbacks to that approach:
Would a console command line parameter be a better solution? We already have Tagging in @nunit/engine-team for their thoughts - let's see what others think about this before going any further. 🙂 |
I've always felt this way about referencing the VSTest adapter from a csproj. :D
|
Yes - same!
And limit it just to take a directory? It seems like an overhead to need to create a separate directory specifically to house a single extension assembly. I think it would be good to also support the .addins file, to be consistent current behaviour. |
Oh, true. |
The search for extensions starts in a root directory, which is the directory containing the engine itself. However, if you are loading multiple assemblies, there is still only one engine with extensions (i.e. the primary engine) It would take a fair bit of effort, I think, to load an extension only for one assembly, possibly a full restructuring of how we load assemblies. For that reason I agree with an approach where the user simply tells the user where to look for extensions. The command-line makes sense for this purpose. All the console would need to do would be to add the new setting to the |
Great! @nvborisenko - does the command line option still work for you, and are you still interested in implementing it? I suggest |
@ChrisMaddock That flexibility (dll/addins/directory) is probably useful for the user even if it takes a bit more work to reorganize the service initialization code. It seems doable. You haven't specified what a directory means. I suggest that it should mean the same thing as if you added the directory path to the addins file. That is: process any .addins files if present OR process *.dll in that directory. This is slightly different from how we process the original engine directory, where we ignore any dlls, but it seems less surprising. |
Me neither. Let's cross that bridge when we come it it. 🙂 There's workarounds, like adding an empty. |
Good point - I agree with what you say! |
If we want to run without any extensions I can imagine a |
Command line option can be considered as working solution. Fifty cents from me:
New idea came: what if engine searches for "*.addins" files in test directory and processes them as usual. Hence user needs create |
Is it will be implemented in soon time ? |
We have discussed but not yet made any decision and nobody has taken the task. |
After some time passed, I am returning back. Actually for me it was enough to hear about that "engine starts look up *.addins file in the folder where it is located". It allowed me create addins file and specify where my addin.dll is located. Particular it worked with NUnit3TestAdapter: Visual Studio loads adapter from "bin\Debug" folder, engine.dll is located there too, and my addin.dll is there too. Using this approach was enough to me. But recently Visual Studio decided to load adapter from nuget package folder, instead of "bin\Debug". As a result approach stopped to work. I lost the actual folder where I understand that extension service should be totally redesigned. What if Easy code change - big profit. |
The nuget install of NUnit should include a It seems to me that CurrentDirectory works for the adapter, at least until VS changes the directory, but doesn't work well generally. For example I can run a command like...
OTOH I've often wanted a way to have NUnit detect that it's running as part of a VS project and use additional addins locations in that case. |
NUnit3Adaper comes with Problems:
Let me remember the topic of this issue: To be more specific: I want to develop "html reporter". User has a test project, user installs "html test reporter" into his test project via nuget - and he gets html report in all ways he executes tests (via console, via adapter). Is it possible? |
I agree that a simplified approach is a good idea. I just don't think the Current Directory is reliable in all cases since the user can be in any directory and still run NUnit3-console. At least for the console, it seems to me that the application base directory would be more reliable. Not sure how that would work for the adapter, however. |
Ooh, glad to see people interested in this issue - it's something I've wanted to look at for a while! My thoughts: the engine itself provides a simple interface to locate extension. How to make that more user-friendly is a situation which is different per runner - any my opinion is that any changes we want to make here would be to the runners, (i.e. the adapter, or console). For example:
For this particular GitHub issue - I'd love to see someone take on a console command such as the above, but I don't (yet!) think any change to the engine is necessary. On the adapter - I'd defer to @OsirisTerje, and suggest a separate issue over in that repo to look at the adapter implementation specifically. 🙂 |
All that said, the point of @nvborisenko's I haven't touched on is being able to install a dependency and have that add-in apply to runs extensions of that test. I'm not sure on this - it's sounds potentially costly performance wise. Remember the engine and extensions are all invoked whenever you run a single test in the adapter/ReSharper. It sounds like it could be a little heavy to investigate every reference of the test assembly for possible |
Adding a small point to the mix here... My expectation was that folks would not modify the provided addins file but would add additional files, perhaps one file per extension, in the same directory. That's why we initially start the search for extensions with a directory rather than a single file. |
A couple of ideas for introduction of new extensions more easily...
|
Here's number 3, which is merely a possible workaround...
|
My expectations:
Based on this, I would like to say that runner/engine should be smart enough to understand what extensions ProjectA or ProjectB want to use. |
I think the first point is overstated. Environment variables may be machine-scoped but may also be user-specific. It depends where they are set and by whom. The second point is true when the extension point for which the extension is written is part of the engine. But if the extension point is in a runner, then extensions have to be runner-specific. Note that right now, extensions are specific to a particular copy of the engine. So their specificity depends on how engines are located and used. For example, extensions to the copy of the engine that is installed by the VS adapter are runner-specific and (usually) user-specific. @nvborisenko I'm not arguing for or against a particular approach here. I'm only trying to point out that there are lots of different sides of the problem and that it's probably not a good idea to make absolute rules saying that anything MUST or MUST NOT be done a certain way. We can each only say what type of setup would be helpful to us. |
Moving this to the 4.0 milestone for resolution. While it could probably be done in a non-breaking way, I think being allowed to break existing behavior in a new major release gives us a bit more freedom to rethink the loading of extensions. |
This has been sitting for a long time, and I would like to revive it and deal with it. Since the 4.0 release seems not very close with nobody working on it, let's review what has been suggested here as a potential new feature for 3.x. Thoughts? |
I raised it, and I have workaround for it (adding Another trend I see is executable test assembly - like NUnitLite, but now is officially advertised. |
@nvborisenko How do you see executable test assemblies as related to extensions? |
PROPOSED New Feature... UPDATED 21 Oct 2024
NOTE: The order of examining directories has no effect other than possible differences in efficiency. The latest version of any extension should always be chosen. If users want a particular version, they should ensure that no later version is included in the specified paths. @nunit and others: Please give me your questions and comments on this, even if you commented earlier in the thread. @jnm2 Some of this matches some ideas you have put forward in the past. |
Here's a new wrinkle I hadn't seen before but which will have to be dealt with. Our netcore runner is a standalone executable, executed as a tool. Standalone executables are actually unmanaged assemblies with the various managed assemblies contained in an directory structure internal to the project. For example, the engine inside the NUnit.ConsoleRunner.NetCore package is found inside the package at relative path That same directory contains our standard nuget This suggests that we may wish to redefine the base path for the addins file as that of the executable itself. For our recent releases, the console exe is in the same directory as the engine, so this would not be a breaking change. (I'll have to research to see how far back this is true.) Alternatively, this could be handled by adding an additional root directory automatically when dealing with a standalone executable. The engine would, in fact, need to detect that it was part of a standalone executable and find it's way up to the top level. That seems feasible. @OsirisTerje @veleek @nunit Any other ideas about how to handle this? |
Issue #1504 introduced an algorithmic approach for locating extensions installed in standard locations relative to the host application. For this issue, all that remains to do is to allow user-specified root directories to examine for extensions as was originally requested. |
Feature Description as Implemented - 7 Dec 2024
NOTES:
|
This issue has been resolved in version 3.19.0 The release is available on: |
Currently there is only one way how user is able to say where
nunit-console
should find extensions. This is via*.addins
file. What if user will be able to install extension via nuget into tests project and that's all what is required from user.I propose to extend nunit-console and try to search extensions in the directory where user's tests dll is located. It would be default behavior.
The text was updated successfully, but these errors were encountered: