Beispiel #1
0
        public IServiceTestStep AddTestStep(string activityUniqueId, string activityDisplayName, string activityTypeName, ObservableCollection <IServiceTestOutput> serviceTestOutputs, StepType stepType)
        {
            if (string.IsNullOrEmpty(activityUniqueId))
            {
                throw new ArgumentNullException(nameof(activityUniqueId));
            }

            if (string.IsNullOrEmpty(activityTypeName))
            {
                throw new ArgumentNullException(nameof(activityTypeName));
            }

            if (serviceTestOutputs == null)
            {
                throw new ArgumentNullException(nameof(serviceTestOutputs));
            }

            var testStep = new ServiceTestStep(Guid.Parse(activityUniqueId), activityTypeName, serviceTestOutputs, stepType)
            {
                StepDescription = activityDisplayName
            };

            TestSteps.Add(testStep);
            return(testStep);
        }
Beispiel #2
0
 private void ResetTest()
 {
     TestComment = string.Empty;
     TestSteps.Clear();
     foreach (var ts in Map(_execution.Steps))
     {
         TestSteps.Add(ts);
     }
 }
Beispiel #3
0
        public override IMessage Invoke(IMessage msg)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("msg", "The message containing invocation information cannot be null");
            }

            IMethodCallMessage methodCall      = msg as IMethodCallMessage;
            MethodInfo         decoratedMethod = methodCall.MethodBase as MethodInfo;

            var           reTryStepTime = 0;
            var           isReTryStep   = false;
            ReturnMessage returnMessage;

            do
            {
                var testStep = CreateTestStep(methodCall, decoratedMethod, TestCaseStatus, Index);
                Logger.LogMsg(Severity.INFO, $"Test step: {testStep.Name} started at: {DateTime.Now}... retry step time: {reTryStepTime}");

                object invokeResult = null;
                try
                {
                    if (testStep.Status == Status.Undefined)
                    {
                        bool isStoppedOnFail = Config.StopOnFail;
                        if (!isReTryStep && isStoppedOnFail && (PreviousStepStatus == Status.Failed || PreviousStepStatus == Status.Skipped))
                        {
                            testStep.SetStatus(Status.Skipped);
                        }
                        else
                        {
                            invokeResult = decoratedMethod.Invoke(this.Decorated, methodCall.Args);
                            testStep.SetValue(invokeResult);
                            testStep.SetStatus(Status.Passed);
                        }
                    }

                    returnMessage = new ReturnMessage(invokeResult, null, 0, methodCall.LogicalCallContext, methodCall);
                }
                catch (Exception ex)
                {
                    var screenName = $"{testStep.ID}_{decoratedMethod.Name}_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.jpeg";
                    testStep.SetScreenshotPath($@"{Config.ReportToScreenshot}\{screenName}");
                    Logger.LogMsg(Severity.ERROR, $"Test step Screenshot file name: {screenName}.");

                    var screenPath = $@"{Config.ScreenshotPath}\{screenName}";
                    FwUtil.Screenshot.CaptureScreen(screenPath);

                    Logger.LogMsg(Severity.ERROR, $"Step exception: {ex.GetLastInnerException().Message}. StackTrace: {ex.GetLastInnerException().StackTrace}");
                    testStep.SetError($"Step exception: {ex.GetLastInnerException().Message}. StackTrace: {ex.GetLastInnerException().StackTrace}");

                    testStep.SetStatus(Status.Failed);
                    returnMessage = new ReturnMessage(invokeResult, null, 0, methodCall.LogicalCallContext, methodCall);
                    // Remark: do not return exception from a step method to test method so that we can continue next step !!!
                    // returnMessage = new ReturnMessage(ex, methodCall);
                }

                testStep.Finish();
                TestSteps.Add(testStep);

                PreviousStepStatus = testStep.Status;
                isReTryStep        = (reTryStepTime < Config.RetryStep && (PreviousStepStatus == Status.Failed));

                Logger.LogMsg(Severity.INFO, $"Test step: {testStep.Name} => Status is: {testStep.Status}...");
                Logger.LogMsg(Severity.INFO, $"Test step: {testStep.Name} completed at: {DateTime.Now}... retry step: {reTryStepTime}");

                reTryStepTime++;
                Index++;
            } while (isReTryStep);

            return(returnMessage);
        }
Beispiel #4
0
        public void AddStep(int stepNumber, string action, string expected)
        {
            TestStep currTestStep = new TestStep(stepNumber, action, expected);

            TestSteps.Add(currTestStep);
        }