Ejemplo n.º 1
0
        public void CanFindActionsAsExpected()
        {
            List <ActionStepsClass> classes = finder.Find(typeof(HasSomeSteps));

            Assert.AreEqual(1, classes.Count);
            ActionStepsClass c = classes[0];

            List <ActionStepMethod> methods = c.ActionStepMethods;

            Assert.AreEqual(6, methods.Count);
            AssertStepMethod(methods[0], StepType.Given, "some precondition");
            AssertStepMethod(methods[1], StepType.Given, "another precondition");
            AssertStepMethod(methods[2], StepType.When, "an actor does some stuff");
            AssertStepMethod(methods[3], StepType.When, "an actor does some more stuff");
            AssertStepMethod(methods[4], StepType.Then, "something weird happens");
            AssertStepMethod(methods[5], StepType.Then, "something even more weird happens");
        }
Ejemplo n.º 2
0
        FeatureResult ExecuteFeature(Feature feature, Type[] types, RunnerOptions options)
        {
            var featureResult = new FeatureResult(feature);
            var matcher       = new StepMatcher();
            var finder        = new ActionStepFinder();

            var steps = GetUniqueSteps(feature);
            var actionStepsClasses = finder.Find(types);
            var matches            = MatchStepsToActionMethods(steps, actionStepsClasses, matcher);
            var executionObjects   = GetExecutionObjects(matches);
            var filter             = options.Filter;

            try
            {
                BeforeFeature(feature, executionObjects);

                foreach (var scenario in feature.Scenarios.SelectMany(s => s.GetExecutableScenarios()).Where(s => filter.IsSatisfiedBy(s.Tags)))
                {
                    BeforeScenario(feature, scenario, executionObjects);
                    var result = ExecuteScenario(scenario, feature, matches, executionObjects, options);
                    featureResult.AddScenarioResult(result);
                    AfterScenario(feature, scenario, result, executionObjects);

                    if (options.SuccessRequired && !result.Success)
                    {
                        break;
                    }
                }

                AfterFeature(feature, featureResult, executionObjects);
            }
            finally
            {
                CleanUpExecutionObjects(executionObjects);
            }

            return(featureResult);
        }