コード例 #1
0
        public void ShouldGetTagListFromExecutionInfo()
        {
            var specInfo = new SpecInfo
            {
                Tags     = { "foo" },
                Name     = "",
                FileName = "",
                IsFailed = false
            };
            var executionInfo = new ExecutionInfo
            {
                CurrentSpec = specInfo
            };
            var currentExecutionInfo = new SpecExecutionEndingRequest
            {
                CurrentExecutionInfo = executionInfo
            };
            var message = new Message
            {
                SpecExecutionEndingRequest = currentExecutionInfo,
                MessageType = Message.Types.MessageType.StepExecutionEnding,
                MessageId   = 0
            };

            var tags = AssertEx.ExecuteProtectedMethod <SpecExecutionEndingProcessor>("GetApplicableTags", message)
                       .ToList();

            Assert.IsNotEmpty(tags);
            Assert.AreEqual(1, tags.Count);
            Assert.Contains("foo", tags);
        }
コード例 #2
0
        public void ShouldGetTagListFromExecutionInfo()
        {
            var specInfo = SpecInfo.CreateBuilder()
                           .AddTags("foo")
                           .SetName("")
                           .SetFileName("")
                           .SetIsFailed(false)
                           .Build();
            var executionInfo = ExecutionInfo.CreateBuilder()
                                .SetCurrentSpec(specInfo)
                                .Build();
            var currentExecutionInfo = SpecExecutionEndingRequest.CreateBuilder()
                                       .SetCurrentExecutionInfo(executionInfo)
                                       .Build();
            var message = Message.CreateBuilder()
                          .SetSpecExecutionEndingRequest(currentExecutionInfo)
                          .SetMessageType(Message.Types.MessageType.SpecExecutionEnding)
                          .SetMessageId(0)
                          .Build();

            var tags = AssertEx.ExecuteProtectedMethod <SpecExecutionEndingProcessor>("GetApplicableTags", message).ToList();

            Assert.IsNotEmpty(tags);
            Assert.AreEqual(1, tags.Count);
            Assert.Contains("foo", tags);
        }
コード例 #3
0
        public ExecutionStatusResponse Process(SpecExecutionEndingRequest request)
        {
            _executionOrchestrator.CloseExecutionScope();
            var result = ExecuteHooks(request.CurrentExecutionInfo);

            ClearCacheForConfiguredLevel();
            return(result);
        }
コード例 #4
0
        public override Task <Empty> NotifySpecExecutionEnding(SpecExecutionEndingRequest request, ServerCallContext context)
        {
            try
            {
                TraceLogger.Info($"{nameof(NotifySpecExecutionEnding)} received");
                TraceLogger.Verbose(System.Text.Json.JsonSerializer.Serialize(request));

                if (request.SpecResult != null)
                {
                    _sender.FinishSpec(request);
                }
            }
            catch (Exception exp)
            {
                TraceLogger.Error(exp.ToString());
            }

            return(Task.FromResult(new Empty()));
        }
コード例 #5
0
        public void ShouldExecuteBeforeSpecHook()
        {
            var request = new SpecExecutionEndingRequest
            {
                CurrentExecutionInfo = new ExecutionInfo
                {
                    CurrentSpec = new SpecInfo()
                }
            };

            var mockMethodExecutor   = new Mock <IExecutionOrchestrator>();
            var protoExecutionResult = new ProtoExecutionResult
            {
                ExecutionTime = 0,
                Failed        = false
            };

            var pendingMessages = new List <string> {
                "one", "two"
            };
            var pendingScreenshotFiles = new List <string> {
                "screenshot.png"
            };

            mockMethodExecutor.Setup(x =>
                                     x.ExecuteHooks("AfterSpec", It.IsAny <HooksStrategy>(), It.IsAny <IList <string> >(),
                                                    It.IsAny <ExecutionContext>()))
            .Returns(protoExecutionResult);
            mockMethodExecutor.Setup(x =>
                                     x.GetAllPendingMessages()).Returns(pendingMessages);
            mockMethodExecutor.Setup(x =>
                                     x.GetAllPendingScreenshotFiles()).Returns(pendingScreenshotFiles);
            var processor = new SpecExecutionEndingProcessor(mockMethodExecutor.Object);

            var result = processor.Process(request);

            Assert.False(result.ExecutionResult.Failed);
            Assert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages);
            Assert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles);
        }
コード例 #6
0
        public void FinishSpec(SpecExecutionEndingRequest request)
        {
            var key = GetSpecKey(request.CurrentExecutionInfo, request.CurrentExecutionInfo.CurrentSpec);

            var specReporter = _specs[key];

            var specResult = request.SpecResult;

            // post hook messages
            if (specResult.ProtoSpec.PostHookMessages.Count != 0 || specResult.ProtoSpec.PostHookFailures.Count != 0)
            {
                foreach (var postHookMessage in specResult.ProtoSpec.PostHookMessages)
                {
                    specReporter.Log(new CreateLogItemRequest
                    {
                        Level = LogLevel.Debug,
                        Text  = postHookMessage,
                        Time  = DateTime.UtcNow
                    });
                }

                foreach (var postHookFailure in specResult.ProtoSpec.PostHookFailures)
                {
                    specReporter.Log(new CreateLogItemRequest
                    {
                        Level = LogLevel.Error,
                        Text  = $"{postHookFailure.ErrorMessage}{Environment.NewLine}{postHookFailure.StackTrace}",
                        Time  = DateTime.UtcNow
                    });
                }
            }

            specReporter.Finish(new FinishTestItemRequest
            {
                EndTime = DateTime.UtcNow
            });

            _specs.TryRemove(key, out _);
        }
コード例 #7
0
 public ExecutionStatusResponse Process(SpecExecutionEndingRequest request)
 {
     _executionOrchestrator.CloseExecutionScope();
     return(ExecuteHooks(request.CurrentExecutionInfo));
 }
コード例 #8
0
 public override Task <ExecutionStatusResponse> FinishSpecExecution(SpecExecutionEndingRequest request, ServerCallContext context)
 {
     return(_pool.Execute(getStream(request.Stream), () => this.specExecutionEndingProcessor.Process(request)));
 }
コード例 #9
0
 public override Task <ExecutionStatusResponse> FinishSpecExecution(SpecExecutionEndingRequest request, ServerCallContext context)
 {
     return(Task.FromResult(this.specExecutionEndingProcessor.Process(request)));
 }
コード例 #10
0
 public override Task <Empty> NotifySpecExecutionEnding(SpecExecutionEndingRequest request, ServerCallContext context)
 {
     return(Task.FromResult(new Empty()));
 }