public void It_should_run_noncontextual_scenarios()
        {
            var ex = Assert.ThrowsAsync <Exception>(() => _runner
                                                    .AddSteps(Step_one)
                                                    .RunAsync());

            Assert.That(ex.Message, Is.EqualTo(nameof(Step_one)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Runs test scenario by executing given steps in specified order.<br/>
        /// If given step throws, other are not executed.<br/>
        /// The scenario name is determined from the current scenario test method.<br/>
        /// Scenario labels are determined from <see cref="LabelAttribute"/> attributes applied on scenario method.<br/>
        /// The step name is determined from lambda parameter name reflecting action type keyword, corresponding action name and passed list of parameters to called method.<br/>
        /// If scenario is executed with context, the context instance is provided with lambda parameter.<br/>
        /// Example usage:
        /// <code>
        /// Runner.RunScenario(
        ///         _ => Given_numbers(5, 8),
        ///         _ => When_I_add_them(),
        ///         _ => I_should_receive_number(13))
        /// </code>
        /// Expected step signature: <code>void Given_numbers(params int[] numbers) { /* ... */ }</code>
        /// </summary>
        /// <param name="runner">Runner.</param>
        /// <param name="steps">List of steps to execute in order.</param>
        public static void RunScenario <TContext>(this IBddRunner <TContext> runner, params Expression <Action <TContext> >[] steps)
        {
            try
            {
                var scenario = runner
                               .AddSteps(steps)
                               .Integrate().Core
                               .WithCapturedScenarioDetails()
                               .Build();

                scenario.ExecuteSync();
            }
            catch (ScenarioExecutionException e)
            {
                e.GetOriginal().Throw();
            }
        }