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

ReportPortal.Shared.Context.Current.Log not working with NUnit.Engine > 3.15.2 #87

Closed
shatulsky opened this issue Jan 26, 2023 · 9 comments
Labels

Comments

@shatulsky
Copy link

Updating NUnit.Engine to the version greater than 3.15.2 breaks ReportPortal.Shared.Context.Current.Log

Packages versions we currently have:

<TargetFramework>net7.0</TargetFramework>

<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit.Engine" Version="3.15.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageReference Include="ReportPortal.NUnit" Version="4.4.1" />
<PackageReference Include="ReportPortal.Shared" Version="3.3.0" />

Test example:

[Test]
public void Log_Test()
{
    ReportPortal.Shared.Context.Launch.Log.Info("launch info");
    ReportPortal.Shared.Context.Launch.Log.Error("launch error");

    ReportPortal.Shared.Context.Current.Log.Info("current info");
    ReportPortal.Shared.Context.Current.Log.Error("current error");

    throw new ArgumentException("Exception");
}

3.15.2 version output:
image

After updating NUnit.Engine version greater than 3.15.2 - the only exception throw is shown on RP UI
image

@nvborisenko nvborisenko transferred this issue from reportportal/commons-net Jan 27, 2023
@nvborisenko
Copy link
Member

nvborisenko commented Jan 27, 2023

Reproduced. Logs are not coming to RP using ReportPortal.Shared.Context.Launch.Log.*("") in case of installing NUnit.Engine v3.16+.

Normal internal logs should be

ExtensionManager Verbose: 0 : 14:30:52.2685204 : 1-testhost : Exploring 'ReportPortal.NUnitExtension, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null' assembly for extensions.
ExtensionManager Verbose: 0 : 14:30:52.2689983 : 1-testhost : Exploring 'ReportPortal.Shared, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null' assembly for extensions.
ExtensionManager Information: 0 : 14:30:52.2694515 : 1-testhost : Registered 'ReportPortal.Shared.Extensibility.Embedded.Analytics.AnalyticsReportEventsObserver' type as IReportEventsObserver extension.
ExtensionManager Verbose: 0 : 14:30:52.2698227 : 1-testhost : Exploring 'ReportPortal.Client, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' assembly for extensions.
ExtensionManager Verbose: 0 : 14:30:52.2702406 : 1-testhost : Exploring 'ReportPortal.NUnitExtension.LogHandler, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null' assembly for extensions.
ExtensionManager Information: 0 : 14:30:52.2705160 : 1-testhost : Registered 'ReportPortal.NUnitExtension.LogHandler.LogMessageHandler' type as ICommandsListener extension.

while with v3.16

ExtensionManager Verbose: 0 : 14:33:17.4591645 : 1-testhost : Exploring 'ReportPortal.NUnitExtension, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null' assembly for extensions.
ExtensionManager Verbose: 0 : 14:33:17.4595204 : 1-testhost : Exploring 'ReportPortal.Shared, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null' assembly for extensions.
ExtensionManager Verbose: 0 : 14:33:17.4598295 : 1-testhost : Exploring 'ReportPortal.Client, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' assembly for extensions.
ExtensionManager Verbose: 0 : 14:33:17.4601851 : 1-testhost : Exploring 'ReportPortal.NUnitExtension.LogHandler, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null' assembly for extensions.

It doesn't find ReportPortal.NUnitExtension.LogHandler.LogMessageHandler type as ICommandsListener

@Aleh-Yanushkevich
Copy link
Contributor

@shatulsky sorry for delay. After investigation we found, that assembly with ReportPortal.NUnitExtension.LogHandler class, which is responsible for sending logs, is loaded twice to app domain. And due to this fact, extension manager is not able to register LogMessageHandler.

It's an issue on NUnit.Engine side and we prepared a solution for reproducing a bug, but found that a some time ago new version of NUnit.Engine was release (3.16.3). And issue with incorrect loading into app domain is gone.

Could you please try to increase version of NUnit.Engine to 3.16.3 and let us know if it helps you?

@shatulsky
Copy link
Author

shatulsky commented Feb 22, 2023

Hello @Aleh-Yanushkevich! Thx for the response.
Updating NUnit.Engine version (3.15.2 -> 3.16.3) in my solution - breaks the building of System.IServiceProvider with this error -
image

So I am not able to confirm the fix

@Aleh-Yanushkevich
Copy link
Contributor

Aleh-Yanushkevich commented Feb 22, 2023

@shatulsky have you changed anything else except version of NUnit.Engine? Because according to exception, ILogger has not been resolved correctly, which mandatory for ApiClient. NUnit.Engine couldn't affect these dependencies.

@shatulsky
Copy link
Author

@Aleh-Yanushkevich
The only change that makes DI break is updating of NUnit.Engine

@nvborisenko
Copy link
Member

Seems the issue is not related to Report Portal anymore. Can you try to install NUnit.Engine.Api package instead of NUnit.Engine? At least it should resolve current issues. If it works, then we will close this issue.

And I suggest to post new issue about your DI containers to NUnit core team, because most likely you will face this issue in upcoming new version of NUnit.TestAdapter.

@shatulsky
Copy link
Author

Using NUnit.Engine.Api 3.16.3 instead of NUnit.Engine fixed DI issue.
So now I am able to use the latest version of all related to tests packages.
image
And report portal logging is also working
image
@nvborisenko, @Aleh-Yanushkevich thx for the help!

@Aleh-Yanushkevich
Copy link
Contributor

@Aleh-Yanushkevich you're welcome!

@nvborisenko
Copy link
Member

Related to nunit/nunit3-vs-adapter#1069

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants