Skip to content

Commit

Permalink
Merge pull request #80 from reportportal/79-the-files-attached-to-the…
Browse files Browse the repository at this point in the history
…-launch-are-actually-attached-to-the-current-test

Attach log items came from user to proper context type
  • Loading branch information
Aleh-Yanushkevich authored Mar 30, 2023
2 parents 8b639a2 + 66c5af7 commit d3eabbb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/ReportPortal.SpecFlowPlugin/ReportPortalAddin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class ReportPortalAddin
{
private static readonly ITraceLogger Logger = TraceLogManager.Instance.GetLogger<ReportPortalAddin>();

public static ILaunchReporter LaunchReporter { get; internal set; }

private static ConcurrentDictionary<FeatureInfo, ITestReporter> FeatureTestReporters { get; } = new ConcurrentDictionary<FeatureInfo, ITestReporter>(new FeatureInfoEqualityComparer());

private static ConcurrentDictionary<FeatureInfo, int> FeatureThreadCount { get; } = new ConcurrentDictionary<FeatureInfo, int>(new FeatureInfoEqualityComparer());
Expand Down
3 changes: 2 additions & 1 deletion src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit d3eabbb

Please sign in to comment.