-
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
ComponentNotRegisteredException when executing test cases using NUnit Console 3.16.3 (Release) #1391
Comments
Can you please check the 3.17 version. The 3.16 series are abandoned, and 3.17 is a continuation of 3.15, which is what is used in the adapter, and thus dotnet and Visual Studio. |
Updated to 3.17. It provides me with the same results. |
Ok, that means the error is in the console code, not in the engine code. Or, that you need to add something to the Autofac registration, that is, scanning is not enough. Suggest you also upload a small repro that reproduce this error. And, do you really need to use the console, can you use |
Raised the question with the Autofac guys, but they dismissed it saying that it is most likely a problem with environment, which is quite fair argument I guess. Our existing pipeline has been using console runner and I was just hoping it would still work onwards. However, thanks for the tip - I just tested it with Do you want me to set up small repo to preproduce this issue that could help you trace what could be wrong with it ? |
Good to hear that dotnet test works for you.
It would be awesome, then we having something to check when we get to this. |
@marossi7 Any more info on this? If not I will close it. BTW, @OsirisTerje commented that the problem is probably not with the engine, because the vs adapter uses the engine. That's not 100% certain as the adapter uses only a subset of the engine's features. In particular, the adapter doesn't create processes, since VS has already created the process used by the tests. |
I see the same issue with version 3.18.1.
|
Do you reference the VS adapter? If so, can you run a test removing that reference? That will help to verify that no engine version conflict is occurring. |
I have the csproj with the following
|
@rodrigo455 Eliminate NUnit3TestAdapter and try a test run. Ideally, your test project should only have the NUnit reference, so you may consider eliminating all other references except for NUnit temporarily. |
Also... where are you invoking code that registers assemblies? Is it located in the SUT or in the test assembly? Are you certain that the registration code is actually invoked when running under NUnit3-Console? |
with just
for my case, It is happening during the |
The problem for me is that I can get the registering code to run from var type = assem.GetType(typeName, true);
Activator.CreateInstance(type); because it can't find other dependent libraries, although they are loaded to the current AppDomain and available at project binary folder. I get as you might notice, it is not an autofac problem..., but a misconfigured environment. not sure how to solve that yet. related to #1313 |
You mentioned #1313 as related. We closed #1313 without action for reasons given here: #1313 (comment) I can look into this issue further but a simple repro example would be of great help. |
My issue is that a dependency of one of the dlls loaded with autofac, use a custom Now, I have a workaround that it is working for me, I had to add a Resolving event, so that custom context looks for dlls into the test project binary directory, if it does not find the |
So, would you consider this resolved or should we keep it? IMO, if the assembly that uses the custom AssemblyLoadContext , is your assembly_ then it's not a bug. The workaround is the solution. But if it's autofac that uses the custom context, then it's a bug... maybe ours, maybe autofac's. :-) In any case, I'm happy to play with it some more if you can give me a very simple repro project to work with. |
Is it fair to assume that the default AssemblyLoadContext should be able to find assemblies where the test libraries are located? anyway, I am fine if you consider this resolved. |
@rodrigo455 I recognize it's a real problem for you but I have to triage issues to choose those which (1) impact the most people and (2) give me enough information to work on this. The latter is why I asked for a repro project. @rodrigo455 @marossi7 If either of you can provide a repro project, I'll debug through it using the latest main and see what can be done. Lacking that, it will require somebody familiar with autofac to step up and volunteer to do a PR. |
Hi, stumbled across this bug and created a simple repro |
Thanks @JulianJmu |
I think this may be related to #1488, which deals with incorrect |
@marossi7 @JulianJmu @rodrigo455 The dev builds in our myget feed now provide the correct |
Since the BaseDirectory problem is solved I'm closing this for the 3.18.3 release. |
This issue has been resolved in version 3.18.3 The release is available on: |
We recently lifted .NET Framework project to .NET 7. All went without major complications, but we encountered an issue when we were trying to execute test cases from a .NET 7 test library using NUnit Console 3.16.3 (Release). The interesting fact is that the tests are running fine when ran from Visual Studio, but as longs as we run them from the console runner the following error is encountered.
In the test case we use IoC (Autofac 7.0.1) and we are loading assembly modules using Module Scanning. Module scanning is performed with the RegisterAssemblyModules() registration method, which does exactly what its name suggests.
When trying to resolve registered assembly / ies (see below) the exception mentioned in the beginning is thrown.
I am not sure this is the correct place to report this, but the whole thing works fine in the Visual Studio environment, but not through the NUnit Console 3.16.3 (Release).
The text was updated successfully, but these errors were encountered: