private void CommandsSource_OnBeginLogScopeCommand(Shared.Execution.ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogScopeCommandArgs args) { var logScope = args.LogScope; var startRequest = new StartTestItemRequest { Name = logScope.Name, StartTime = logScope.BeginTime, HasStats = false }; ITestReporter testReporter = null; if (logScope.Parent != null) { if (ReportPortalAddin.LogScopes.ContainsKey(logScope.Parent.Id)) { testReporter = ReportPortalAddin.LogScopes[logScope.Parent.Id]; } } else { testReporter = GetCurrentTestReporter(); } if (testReporter != null) { var nestedStep = testReporter.StartChildTestReporter(startRequest); ReportPortalAddin.LogScopes[logScope.Id] = nestedStep; } else { _traceLogger.Warn("Unknown current step context to begin new log scope."); } }
private void CommandsSource_OnLogMessageCommand(Shared.Execution.ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogMessageCommandArgs args) { var logScope = args.LogScope; ITestReporter testReporter; if (logScope != null && ReportPortalAddin.LogScopes.ContainsKey(logScope.Id)) { testReporter = ReportPortalAddin.LogScopes[logScope.Id]; } else { // TODO: investigate SpecFlow how to understand current scenario context testReporter = GetCurrentTestReporter(); } if (testReporter != null) { testReporter.Log(args.LogMessage.ConvertToRequest()); } else { _traceLogger.Warn("Unknown current context to log message."); } }
private void CommandsSource_OnLogMessageCommand(Shared.Execution.ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogMessageCommandArgs args) { var rootScope = Context.Current.Log.Root; TraceLogger.Verbose($"Handling log message for {rootScope.GetHashCode()} root scope..."); var logScope = args.LogScope; if (_outputHelperMap.TryGetValue(rootScope, out ITestOutputHelper output)) { var logRequest = args.LogMessage.ConvertToRequest(); var sharedLogMessage = new AddLogCommunicationMessage { ParentScopeId = logScope?.Id, Level = logRequest.Level, Time = logRequest.Time, Text = logRequest.Text }; if (logRequest.Attach != null) { sharedLogMessage.Attach = new Attach(logRequest.Attach.MimeType, logRequest.Attach.Data); } NotifyAgent(output, Client.Converters.ModelSerializer.Serialize <AddLogCommunicationMessage>(sharedLogMessage)); } }
private void CommandsSource_OnEndLogScopeCommand(Shared.Execution.ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogScopeCommandArgs args) { var logScope = args.LogScope; if (_outputHelperMap.TryGetValue(Context.Current.Log.Root, out ITestOutputHelper output)) { var communicationMessage = new EndScopeCommunicationMessage { Id = logScope.Id, EndTime = logScope.EndTime.Value, Status = logScope.Status }; NotifyAgent(output, Client.Converters.ModelSerializer.Serialize <EndScopeCommunicationMessage>(communicationMessage)); } }
private void CommandsSource_OnBeginLogScopeCommand(Shared.Execution.ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogScopeCommandArgs args) { var logScope = args.LogScope; if (_outputHelperMap.TryGetValue(Context.Current.Log.Root, out ITestOutputHelper output)) { var communicationMessage = new BeginScopeCommunicationMessage { Id = logScope.Id, ParentScopeId = logScope.Parent?.Id, Name = logScope.Name, BeginTime = logScope.BeginTime }; NotifyAgent(output, Client.Converters.ModelSerializer.Serialize <BeginScopeCommunicationMessage>(communicationMessage)); } }
private void CommandsSource_OnEndLogScopeCommand(Shared.Execution.ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogScopeCommandArgs args) { var logScope = args.LogScope; var finishRequest = new FinishTestItemRequest { EndTime = logScope.EndTime.Value, Status = _nestedStepStatusMap[logScope.Status] }; if (ReportPortalAddin.LogScopes.ContainsKey(logScope.Id)) { ReportPortalAddin.LogScopes[logScope.Id].Finish(finishRequest); ReportPortalAddin.LogScopes.TryRemove(logScope.Id, out ITestReporter _); } else { _traceLogger.Warn($"Unknown current step context to end log scope with `{logScope.Id}` ID."); } }