void ITestTracer.TraceStepPending(BindingMatch match, object[] arguments)
 {
     TraceStepPending(match, arguments);
     AllureLifecycle.Instance.StopStep(x => x.status = Status.skipped);
 }
Beispiel #2
0
        private void ExecuteStep(IContextManager contextManager, StepInstance stepInstance)
        {
            HandleBlockSwitch(stepInstance.StepDefinitionType.ToScenarioBlock());

            _testTracer.TraceStep(stepInstance, true);

            bool isStepSkipped       = contextManager.ScenarioContext.ScenarioExecutionStatus != ScenarioExecutionStatus.OK;
            bool onStepStartExecuted = false;

            BindingMatch match = null;

            object[] arguments = null;
            try
            {
                match = GetStepMatch(stepInstance);
                contextManager.StepContext.StepInfo.BindingMatch = match;
                contextManager.StepContext.StepInfo.StepInstance = stepInstance;
                arguments = GetExecuteArguments(match);

                if (isStepSkipped)
                {
                    OnSkipStep();
                }
                else
                {
                    _obsoleteStepHandler.Handle(match);

                    onStepStartExecuted = true;
                    OnStepStart();
                    TimeSpan duration = ExecuteStepMatch(match, arguments);
                    if (_specFlowConfiguration.TraceSuccessfulSteps)
                    {
                        _testTracer.TraceStepDone(match, arguments, duration);
                    }
                }
            }
            catch (PendingStepException)
            {
                Debug.Assert(match != null);
                Debug.Assert(arguments != null);

                _testTracer.TraceStepPending(match, arguments);
                contextManager.ScenarioContext.PendingSteps.Add(
                    _stepFormatter.GetMatchText(match, arguments));

                if (contextManager.ScenarioContext.ScenarioExecutionStatus < ScenarioExecutionStatus.StepDefinitionPending)
                {
                    contextManager.ScenarioContext.ScenarioExecutionStatus = ScenarioExecutionStatus.StepDefinitionPending;
                }
            }
            catch (MissingStepDefinitionException)
            {
                if (contextManager.ScenarioContext.ScenarioExecutionStatus < ScenarioExecutionStatus.UndefinedStep)
                {
                    contextManager.ScenarioContext.ScenarioExecutionStatus = ScenarioExecutionStatus.UndefinedStep;
                }
            }
            catch (BindingException ex)
            {
                _testTracer.TraceBindingError(ex);
                if (contextManager.ScenarioContext.ScenarioExecutionStatus < ScenarioExecutionStatus.BindingError)
                {
                    contextManager.ScenarioContext.ScenarioExecutionStatus = ScenarioExecutionStatus.BindingError;
                    contextManager.ScenarioContext.TestError = ex;
                }
            }
            catch (Exception ex)
            {
                _testTracer.TraceError(ex);

                if (contextManager.ScenarioContext.ScenarioExecutionStatus < ScenarioExecutionStatus.TestError)
                {
                    contextManager.ScenarioContext.ScenarioExecutionStatus = ScenarioExecutionStatus.TestError;
                    contextManager.ScenarioContext.TestError = ex;
                }

                if (_specFlowConfiguration.StopAtFirstError)
                {
                    throw;
                }
            }
            finally
            {
                if (onStepStartExecuted)
                {
                    OnStepEnd();
                }
            }
        }
Beispiel #3
0
        private BindingMatch Match(StepBinding stepBinding, StepArgs stepArgs, bool useParamMatching, bool useScopeMatching)
        {
            Match match = stepBinding.Regex.Match(stepArgs.Text);

            // Check if regexp is a match
            if (!match.Success)
                return null;

            int scopeMatches = 0;
            if (useScopeMatching && stepBinding.IsScoped)
            {
                if (!stepBinding.BindingScope.Match(stepArgs.StepContext, out scopeMatches))
                    return null;
            }

            var bindingMatch = new BindingMatch(stepBinding, match, CalculateExtraArgs(stepArgs), stepArgs, scopeMatches);

            if (useParamMatching)
            {
                // check if the regex + extra arguments match to the binding method parameters
                if (bindingMatch.Arguments.Length != stepBinding.ParameterTypes.Length)
                    return null;

                // Check if regex & extra arguments can be converted to the method parameters
                if (bindingMatch.Arguments.Where(
                    (arg, argIndex) => !CanConvertArg(arg, stepBinding.ParameterTypes[argIndex])).Any())
                    return null;
            }
            return bindingMatch;
        }
Beispiel #4
0
        private TimeSpan ExecuteStepMatch(BindingMatch match, object[] arguments)
        {
            OnStepStart();
            TimeSpan duration;
            match.StepBinding.InvokeAction(arguments, testTracer, out duration);
            OnStepEnd();

            return duration;
        }
 public void TraceStepPending(BindingMatch match, object[] arguments)
 {
     Console.WriteLine("TraceStepPending");
 }
Beispiel #6
0
 public void TraceStepPending(BindingMatch match, object[] arguments)
 {
     traceListener.WriteToolOutput("pending: {0}",
                                   stepFormatter.GetMatchText(match, arguments));
 }
Beispiel #7
0
 public void TraceStepPending(BindingMatch match, object[] arguments)
 {
     traceListener.WriteToolOutput("pending: {0}",
         stepFormatter.GetMatchText(match, arguments));
 }
Beispiel #8
0
 void ITestTracer.TraceStepPending(BindingMatch match, object[] arguments)
 {
     base.TraceStepPending(match, arguments);
     allure.StopStep(x => x.status = Status.skipped);
 }
Beispiel #9
0
        private void ExecuteStep(StepInstance stepInstance)
        {
            HandleBlockSwitch(stepInstance.StepDefinitionType.ToScenarioBlock());

            testTracer.TraceStep(stepInstance, true);

            bool isStepSkipped = contextManager.ScenarioContext.TestStatus != TestStatus.OK;

            BindingMatch match = null;

            object[] arguments = null;
            try
            {
                match     = GetStepMatch(stepInstance);
                arguments = GetExecuteArguments(match);

                if (isStepSkipped)
                {
                    testTracer.TraceStepSkipped();
                }
                else
                {
                    OnStepStart();
                    TimeSpan duration = ExecuteStepMatch(match, arguments);
                    if (runtimeConfiguration.TraceSuccessfulSteps)
                    {
                        testTracer.TraceStepDone(match, arguments, duration);
                    }
                }
            }
            catch (PendingStepException)
            {
                Debug.Assert(match != null);
                Debug.Assert(arguments != null);

                testTracer.TraceStepPending(match, arguments);
                contextManager.ScenarioContext.PendingSteps.Add(
                    stepFormatter.GetMatchText(match, arguments));

                if (contextManager.ScenarioContext.TestStatus < TestStatus.StepDefinitionPending)
                {
                    contextManager.ScenarioContext.TestStatus = TestStatus.StepDefinitionPending;
                }
            }
            catch (MissingStepDefinitionException)
            {
                if (contextManager.ScenarioContext.TestStatus < TestStatus.MissingStepDefinition)
                {
                    contextManager.ScenarioContext.TestStatus = TestStatus.MissingStepDefinition;
                }
            }
            catch (BindingException ex)
            {
                testTracer.TraceBindingError(ex);
                if (contextManager.ScenarioContext.TestStatus < TestStatus.BindingError)
                {
                    contextManager.ScenarioContext.TestStatus = TestStatus.BindingError;
                    contextManager.ScenarioContext.TestError  = ex;
                }
            }
            catch (Exception ex)
            {
                testTracer.TraceError(ex);

                if (contextManager.ScenarioContext.TestStatus < TestStatus.TestError)
                {
                    contextManager.ScenarioContext.TestStatus = TestStatus.TestError;
                    contextManager.ScenarioContext.TestError  = ex;
                }
                if (runtimeConfiguration.StopAtFirstError)
                {
                    throw;
                }
            }
            finally
            {
                if (!isStepSkipped)
                {
                    OnStepEnd();
                }
            }
        }
Beispiel #10
0
 public void TraceStepDone(BindingMatch match, object[] arguments, TimeSpan duration)
 {
     traceListener.WriteToolOutput("done: {0} ({1:F1}s)",
         stepFormatter.GetMatchText(match, arguments), duration.TotalSeconds);
 }
Beispiel #11
0
 void ITestTracer.TraceStepPending(BindingMatch match, object[] arguments)
 {
     base.TraceStepPending(match, arguments);
     AllureAdapter.Instance.PendingStep();
 }
Beispiel #12
0
 void ITestTracer.TraceStepDone(BindingMatch match, object[] arguments, TimeSpan duration)
 {
     base.TraceStepDone(match, arguments, duration);
     AllureAdapter.Instance.FinishStep();
 }
Beispiel #13
0
        public string GetMatchText(BindingMatch match, object[] arguments)
        {
            var methodInfo = match.StepBinding.MethodInfo;

            return(GetMatchText(methodInfo, arguments));
        }
Beispiel #14
0
        private void ExecuteStep(StepArgs stepArgs)
        {
            testTracer.TraceStep(stepArgs, true);

            HandleBlockSwitch(stepArgs.Type.ToScenarioBlock());

            BindingMatch match = null;

            object[] arguments = null;
            try
            {
                match     = GetStepMatch(stepArgs);
                arguments = GetExecuteArguments(match);

                if (ObjectContainer.ScenarioContext.TestStatus == TestStatus.OK)
                {
                    TimeSpan duration = ExecuteStepMatch(match, arguments);
                    if (RuntimeConfiguration.Current.TraceSuccessfulSteps)
                    {
                        testTracer.TraceStepDone(match, arguments, duration);
                    }
                }
                else
                {
                    testTracer.TraceStepSkipped();
                }
            }
            catch (PendingStepException)
            {
                Debug.Assert(match != null);
                Debug.Assert(arguments != null);

                testTracer.TraceStepPending(match, arguments);
                ObjectContainer.ScenarioContext.PendingSteps.Add(
                    stepFormatter.GetMatchText(match, arguments));

                if (ObjectContainer.ScenarioContext.TestStatus < TestStatus.StepDefinitionPending)
                {
                    ObjectContainer.ScenarioContext.TestStatus = TestStatus.StepDefinitionPending;
                }
            }
            catch (MissingStepDefinitionException)
            {
                if (ObjectContainer.ScenarioContext.TestStatus < TestStatus.MissingStepDefinition)
                {
                    ObjectContainer.ScenarioContext.TestStatus = TestStatus.MissingStepDefinition;
                }
            }
            catch (BindingException ex)
            {
                testTracer.TraceBindingError(ex);
                if (ObjectContainer.ScenarioContext.TestStatus < TestStatus.BindingError)
                {
                    ObjectContainer.ScenarioContext.TestStatus = TestStatus.BindingError;
                    ObjectContainer.ScenarioContext.TestError  = ex;
                }
            }
            catch (Exception ex)
            {
                testTracer.TraceError(ex);

                if (ObjectContainer.ScenarioContext.TestStatus < TestStatus.TestError)
                {
                    ObjectContainer.ScenarioContext.TestStatus = TestStatus.TestError;
                    ObjectContainer.ScenarioContext.TestError  = ex;
                }
                if (RuntimeConfiguration.Current.StopAtFirstError)
                {
                    throw;
                }
            }
        }
Beispiel #15
0
 public void TraceStepPending(BindingMatch match, object[] arguments)
 {
     throw new NotImplementedException();
 }
Beispiel #16
0
 void ITestTracer.TraceStepDone(BindingMatch match, object[] arguments, TimeSpan duration)
 {
     base.TraceStepDone(match, arguments, duration);
     allure.StopStep(x => x.status = Status.passed);
 }
Beispiel #17
0
 public void TraceStepDone(BindingMatch match, object[] arguments, TimeSpan duration)
 {
     throw new NotImplementedException();
 }
 public void TraceStepDone(BindingMatch match, object[] arguments, TimeSpan duration)
 {
 }
Beispiel #19
0
 protected virtual void ExecuteStepMatch(BindingMatch match, object[] arguments, out TimeSpan duration)
 {
     _bindingInvoker.InvokeBinding(match.StepBinding, _contextManager, arguments, _testTracer, out duration);
 }
Beispiel #20
0
 public void TraceStepDone(BindingMatch match, object[] arguments, TimeSpan duration)
 {
     traceListener.WriteToolOutput("done: {0} ({1:F1}s)",
                                   stepFormatter.GetMatchText(match, arguments), duration.TotalSeconds);
 }
Beispiel #21
0
 public Exception GetParameterCountError(BindingMatch match, int expectedParameterCount)
 {
     return new BindingException(
         string.Format("Parameter count mismatch! The binding method '{0}' should have {1} parameters",
             GetMethodText(match.StepBinding.MethodInfo), expectedParameterCount));
 }
Beispiel #22
0
 public string GetMatchText(BindingMatch match, object[] arguments)
 {
     var methodInfo = match.StepBinding.MethodInfo;
     return GetMatchText(methodInfo, arguments);
 }
Beispiel #23
0
 public string GetMatchText(BindingMatch match, object[] arguments)
 {
     return(GetMatchText(match.StepBinding.Method, arguments));
 }
Beispiel #24
0
        private object[] GetExecuteArguments(BindingMatch match)
        {
            if (match.Arguments.Length != match.StepBinding.ParameterTypes.Length)
                throw errorProvider.GetParameterCountError(match, match.Arguments.Length);

            var arguments = match.Arguments.Select(
                (arg, argIndex) => ConvertArg(arg, match.StepBinding.ParameterTypes[argIndex]))
                .ToArray();

            return arguments;
        }
Beispiel #25
0
 public Exception GetParameterCountError(BindingMatch match, int expectedParameterCount)
 {
     return(new BindingException(
                string.Format("Parameter count mismatch! The binding method '{0}' should have {1} parameters",
                              GetMethodText(match.StepBinding.Method), expectedParameterCount)));
 }
Beispiel #26
0
        private object[] GetExecuteArguments(BindingMatch match)
        {
            List<object> arguments = new List<object>();

            var regexArgs = match.Match.Groups.Cast<Group>().Skip(1).Select(g => g.Value).ToArray();

            if (regexArgs.Length + match.ExtraArguments.Length != match.StepBinding.ParameterTypes.Length)
                throw errorProvider.GetParameterCountError(match, regexArgs.Length + match.ExtraArguments.Length);

            CultureInfo cultureInfo = FeatureContext.Current.BindingCulture;
            for (int regexArgIndex = 0; regexArgIndex < regexArgs.Length; regexArgIndex++)
            {
                Type parameterType = match.StepBinding.ParameterTypes[regexArgIndex];

                var convertedArg = stepArgumentTypeConverter.Convert(
                    regexArgs[regexArgIndex], parameterType, cultureInfo);
                arguments.Add(convertedArg);
            }

            arguments.AddRange(match.ExtraArguments);

            if (arguments.Count != match.StepBinding.ParameterTypes.Length)
                throw errorProvider.GetParameterCountError(match, arguments.Count);

            return arguments.ToArray();
        }
 void ITestTracer.TraceStepDone(BindingMatch match, object[] arguments, TimeSpan duration)
 {
     TraceStepDone(match, arguments, duration);
     AllureLifecycle.Instance.StopStep(x => x.status = Status.passed);
 }