public void ShouldGetTagListFromScenarioAndSpecAndIgnoreDuplicates() { var specInfo = new SpecInfo { Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var scenarioInfo = new ScenarioInfo { Tags = { "foo" }, Name = "", IsFailed = false }; var currentScenario = new ExecutionInfo { CurrentScenario = scenarioInfo, CurrentSpec = specInfo }; var currentExecutionInfo = new StepExecutionStartingRequest { CurrentExecutionInfo = currentScenario }; var tags = AssertEx.ExecuteProtectedMethod <StepExecutionStartingProcessor>("GetApplicableTags", currentScenario) .ToList(); Assert.IsNotEmpty(tags); Assert.AreEqual(1, tags.Count); Assert.Contains("foo", tags); }
public void ShouldGetTagListFromScenarioAndSpecAndIgnoreDuplicates() { var specInfo = SpecInfo.CreateBuilder() .AddTags("foo") .SetName("") .SetFileName("") .SetIsFailed(false) .Build(); var scenarioInfo = ScenarioInfo.CreateBuilder() .AddTags("foo") .SetName("") .SetIsFailed(false) .Build(); var currentScenario = ExecutionInfo.CreateBuilder() .SetCurrentScenario(scenarioInfo) .SetCurrentSpec(specInfo) .Build(); var currentExecutionInfo = StepExecutionStartingRequest.CreateBuilder() .SetCurrentExecutionInfo(currentScenario) .Build(); var message = Message.CreateBuilder() .SetStepExecutionStartingRequest(currentExecutionInfo) .SetMessageType(Message.Types.MessageType.StepExecutionStarting) .SetMessageId(0) .Build(); var tags = AssertEx.ExecuteProtectedMethod <StepExecutionStartingProcessor>("GetApplicableTags", message).ToList(); Assert.IsNotEmpty(tags); Assert.AreEqual(1, tags.Count); Assert.Contains("foo", tags); }
public void ShouldClearExistingGaugeMessages() { var mockExecutionHelper = new Mock <IExecutionOrchestrator>(); var request = new StepExecutionStartingRequest { CurrentExecutionInfo = new ExecutionInfo { CurrentSpec = new SpecInfo(), CurrentScenario = new ScenarioInfo() } }; var protoExecutionResult = new ProtoExecutionResult { ExecutionTime = 0, Failed = false }; mockExecutionHelper.Setup(executor => executor.ExecuteHooks(It.IsAny <string>(), It.IsAny <HooksStrategy>(), It.IsAny <IList <string> >(), It.IsAny <ExecutionContext>())) .Returns(protoExecutionResult); var hookRegistry = new Mock <IHookRegistry>(); hookRegistry.Setup(registry => registry.BeforeStepHooks).Returns(new HashSet <IHookMethod>()); var pendingMessages = new List <string> { "one", "two" }; var pendingScreenshotFiles = new List <string> { "screenshot.png" }; mockExecutionHelper.Setup(x => x.ExecuteHooks("BeforeStep", It.IsAny <HooksStrategy>(), It.IsAny <IList <string> >(), It.IsAny <ExecutionContext>())) .Returns(protoExecutionResult); mockExecutionHelper.Setup(x => x.GetAllPendingMessages()).Returns(pendingMessages); mockExecutionHelper.Setup(x => x.GetAllPendingScreenshotFiles()).Returns(pendingScreenshotFiles); var processor = new StepExecutionStartingProcessor(mockExecutionHelper.Object); var result = processor.Process(request); Assert.AreEqual(result.ExecutionResult.Message, pendingMessages); Assert.AreEqual(result.ExecutionResult.ScreenshotFiles, pendingScreenshotFiles); }
public override Task <Empty> NotifyStepExecutionStarting(StepExecutionStartingRequest request, ServerCallContext context) { try { TraceLogger.Info($"{nameof(NotifyStepExecutionStarting)} received"); TraceLogger.Verbose(System.Text.Json.JsonSerializer.Serialize(request)); if (request.StepResult != null) { _sender.StartStep(request); } } catch (Exception exp) { TraceLogger.Error(exp.ToString()); } return(Task.FromResult(new Empty())); }
public void ShouldGetTagListFromScenarioAndSpec() { var specInfo = new SpecInfo { Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var scenarioInfo = new ScenarioInfo { Tags = { "bar" }, Name = "", IsFailed = false }; var currentScenario = new ExecutionInfo { CurrentScenario = scenarioInfo, CurrentSpec = specInfo }; var currentExecutionInfo = new StepExecutionStartingRequest { CurrentExecutionInfo = currentScenario }; var message = new Message { StepExecutionStartingRequest = currentExecutionInfo, MessageType = Message.Types.MessageType.ScenarioExecutionStarting, MessageId = 0 }; var tags = AssertEx.ExecuteProtectedMethod <StepExecutionStartingProcessor>("GetApplicableTags", message) .ToList(); Assert.IsNotEmpty(tags); Assert.AreEqual(2, tags.Count); Assert.Contains("foo", tags); Assert.Contains("bar", tags); }
public ExecutionStatusResponse Process(StepExecutionStartingRequest request) { return(ExecuteHooks(request.CurrentExecutionInfo)); }
public override Task <ExecutionStatusResponse> StartStepExecution(StepExecutionStartingRequest request, ServerCallContext context) { return(_pool.Execute(getStream(request.Stream), () => this.stepExecutionStartingProcessor.Process(request))); }
public override Task <ExecutionStatusResponse> StartStepExecution(StepExecutionStartingRequest request, ServerCallContext context) { return(Task.FromResult(this.stepExecutionStartingProcessor.Process(request))); }
public override Task <Empty> NotifyStepExecutionStarting(StepExecutionStartingRequest request, ServerCallContext context) { return(Task.FromResult(new Empty())); }
public void StartStep(StepExecutionStartingRequest request) { var stepResult = request.StepResult; var key = GetStepKey(request.CurrentExecutionInfo, request.CurrentExecutionInfo.CurrentSpec, request.CurrentExecutionInfo.CurrentScenario, request.CurrentExecutionInfo.CurrentStep); TraceLogger.Verbose($"Starting step with key: {key}"); var scenarioReporter = _scenarios[GetScenarioKey(request.CurrentExecutionInfo, request.CurrentExecutionInfo.CurrentSpec, request.CurrentExecutionInfo.CurrentScenario)]; var stepName = stepResult.ProtoItem.Step.ActualText; #region step parameter if (stepResult.ProtoItem.Step.Fragments != null) { foreach (var fragment in stepResult.ProtoItem.Step.Fragments.Where(f => f.FragmentType == Fragment.Types.FragmentType.Parameter && f.Parameter.ParameterType == Parameter.Types.ParameterType.Dynamic)) { stepName = stepName.Replace($"<{fragment.Parameter.Name}>", $"\"{fragment.Parameter.Value}\""); } } #endregion var stepReporter = scenarioReporter.StartChildTestReporter(new StartTestItemRequest { Type = TestItemType.Step, StartTime = DateTime.UtcNow, Name = stepName, HasStats = false }); #region step table //if step argument is table var tableParameter = stepResult.ProtoItem.Step.Fragments.FirstOrDefault(f => f.Parameter?.Table != null)?.Parameter.Table; if (tableParameter != null) { var text = "| **" + string.Join("** | **", tableParameter.Headers.Cells.ToArray()) + "** |"; text += Environment.NewLine + "| " + string.Join(" | ", tableParameter.Headers.Cells.Select(c => "---")) + " |"; foreach (var tableRow in tableParameter.Rows) { text += Environment.NewLine + "| " + string.Join(" | ", tableRow.Cells.ToArray()) + " |"; } stepReporter.Log(new CreateLogItemRequest { Time = DateTime.UtcNow, Level = LogLevel.Info, Text = text }); } // if dynamic arguments var dynamicParameteres = stepResult.ProtoItem.Step.Fragments.Where(f => f.FragmentType == Fragment.Types.FragmentType.Parameter && f.Parameter.ParameterType == Parameter.Types.ParameterType.Dynamic).Select(f => f.Parameter); if (dynamicParameteres.Count() != 0) { var text = ""; foreach (var dynamicParameter in dynamicParameteres) { text += $"{Environment.NewLine}{dynamicParameter.Name}: {dynamicParameter.Value}"; } } #endregion // pre hook messages if (stepResult.ProtoItem.Step.PreHookMessages.Count != 0) { foreach (var preHookMessage in stepResult.ProtoItem.Step.PreHookMessages) { stepReporter.Log(new CreateLogItemRequest { Level = LogLevel.Debug, Text = preHookMessage, Time = DateTime.UtcNow }); } } _steps[key] = stepReporter; }