示例#1
0
 public void Run(nspec instance)
 {
     if (CanRun(instance))
     {
         ContextUtils.RunAndHandleException(InvokeHooks, instance, ref exception);
     }
 }
示例#2
0
        public void Exercise(nspec instance)
        {
            if (example.ShouldSkip(instance.tagsFilter))
            {
                return;
            }

            example.HasRun = true;

            if (example.Pending)
            {
                ContextUtils.RunAndHandleException(example.RunPending, instance, ref example.Exception);

                return;
            }

            var stopWatch = example.StartTiming();

            using (new ConsoleCatcher(output => example.CapturedOutput = output))
            {
                context.BeforeChain.Run(instance);

                context.ActChain.Run(instance);

                if (CanRun())
                {
                    ContextUtils.RunAndHandleException(example.Run, instance, ref example.Exception);
                }

                context.AfterChain.Run(instance);
            }

            // when an expected exception is thrown and is set to be cleared by 'expect<>',
            // a subsequent exception thrown in 'after' hooks would go unnoticed, so do not clear in this case

            if (context.AfterChain.AnyThrew())
            {
                context.ClearExpectedException = false;
            }

            example.StopTiming(stopWatch);
        }