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..a34e864 100644 --- a/src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs +++ b/src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs @@ -67,8 +67,9 @@ public static void BeforeTestRun() _launchReporter.Start(request); ReportPortalAddin.OnAfterRunStarted(null, new RunStartedEventArgs(_service, request, _launchReporter)); - } + + ReportPortalAddin.LaunchReporter = _launchReporter; } catch (Exception exp) {