From 46cb76db53b030c040d0ef7ef8e70c948b78e851 Mon Sep 17 00:00:00 2001 From: AlehYanushklevich Date: Thu, 30 Mar 2023 11:25:32 +0300 Subject: [PATCH 1/2] fixed issue with attaching files to launch. --- .../LogHandler/ContextAwareLogHandler.cs | 13 ++++++++++--- .../ReportPortalAddin.cs | 2 ++ .../ReportPortalHooks.cs | 5 +++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ReportPortal.SpecFlowPlugin/LogHandler/ContextAwareLogHandler.cs b/src/ReportPortal.SpecFlowPlugin/LogHandler/ContextAwareLogHandler.cs index 4b196fe..b0bccfb 100644 --- a/src/ReportPortal.SpecFlowPlugin/LogHandler/ContextAwareLogHandler.cs +++ b/src/ReportPortal.SpecFlowPlugin/LogHandler/ContextAwareLogHandler.cs @@ -1,5 +1,6 @@ using ReportPortal.Client.Abstractions.Models; using ReportPortal.Client.Abstractions.Requests; +using ReportPortal.Shared.Execution; using ReportPortal.Shared.Execution.Logging; using ReportPortal.Shared.Extensibility; using ReportPortal.Shared.Extensibility.Commands; @@ -22,8 +23,14 @@ public void Initialize(ICommandsSource commandsSource) commandsSource.OnLogMessageCommand += CommandsSource_OnLogMessageCommand; } - private void CommandsSource_OnLogMessageCommand(Shared.Execution.ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogMessageCommandArgs args) + private void CommandsSource_OnLogMessageCommand(ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogMessageCommandArgs args) { + if (logContext is ILaunchContext && ReportPortalAddin.LaunchReporter != null) + { + ReportPortalAddin.LaunchReporter.Log(args.LogMessage.ConvertToRequest()); + return; + } + var logScope = args.LogScope; ITestReporter testReporter; @@ -48,7 +55,7 @@ private void CommandsSource_OnLogMessageCommand(Shared.Execution.ILogContext log } } - private void CommandsSource_OnBeginLogScopeCommand(Shared.Execution.ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogScopeCommandArgs args) + private void CommandsSource_OnBeginLogScopeCommand(ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogScopeCommandArgs args) { var logScope = args.LogScope; @@ -84,7 +91,7 @@ private void CommandsSource_OnBeginLogScopeCommand(Shared.Execution.ILogContext } } - private void CommandsSource_OnEndLogScopeCommand(Shared.Execution.ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogScopeCommandArgs args) + private void CommandsSource_OnEndLogScopeCommand(ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogScopeCommandArgs args) { var logScope = args.LogScope; diff --git a/src/ReportPortal.SpecFlowPlugin/ReportPortalAddin.cs b/src/ReportPortal.SpecFlowPlugin/ReportPortalAddin.cs index 601f400..1b62aab 100644 --- a/src/ReportPortal.SpecFlowPlugin/ReportPortalAddin.cs +++ b/src/ReportPortal.SpecFlowPlugin/ReportPortalAddin.cs @@ -11,6 +11,8 @@ public class ReportPortalAddin { private static readonly ITraceLogger Logger = TraceLogManager.Instance.GetLogger(); + public static ILaunchReporter LaunchReporter { get; internal set; } + private static ConcurrentDictionary FeatureTestReporters { get; } = new ConcurrentDictionary(new FeatureInfoEqualityComparer()); private static ConcurrentDictionary FeatureThreadCount { get; } = new ConcurrentDictionary(new FeatureInfoEqualityComparer()); diff --git a/src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs b/src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs index c71b612..efcd25f 100644 --- a/src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs +++ b/src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs @@ -63,12 +63,13 @@ public static void BeforeTestRun() Shared.Extensibility.Embedded.Analytics.AnalyticsReportEventsObserver.DefineConsumer("agent-dotnet-specflow"); _launchReporter = _launchReporter ?? new LaunchReporter(_service, config, null, Shared.Extensibility.ExtensionManager.Instance); - + _launchReporter.Start(request); ReportPortalAddin.OnAfterRunStarted(null, new RunStartedEventArgs(_service, request, _launchReporter)); - } + + ReportPortalAddin.LaunchReporter = _launchReporter; } catch (Exception exp) { From 66c5af7fcf4d4fa194edc821d5dabc02957e8272 Mon Sep 17 00:00:00 2001 From: AlehYanushklevich Date: Thu, 30 Mar 2023 11:26:56 +0300 Subject: [PATCH 2/2] removed spaces. --- src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs b/src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs index efcd25f..a34e864 100644 --- a/src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs +++ b/src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs @@ -63,7 +63,7 @@ public static void BeforeTestRun() Shared.Extensibility.Embedded.Analytics.AnalyticsReportEventsObserver.DefineConsumer("agent-dotnet-specflow"); _launchReporter = _launchReporter ?? new LaunchReporter(_service, config, null, Shared.Extensibility.ExtensionManager.Instance); - + _launchReporter.Start(request); ReportPortalAddin.OnAfterRunStarted(null, new RunStartedEventArgs(_service, request, _launchReporter));