Exemple #1
0
        void ITestCaseFilter.RunTest(TestExecutionContext context, Action <TestExecutionContext> next)
        {
            var adapt = (context.TestObject as ITestExecutionFilter) ?? TestExecutionFilter.Null;

            adapt.BeforeExecuting(context);

            // If the test object implements this ITestCaseFilter interface, then
            // this is a _substitute_ for the default execution logic.  THe main
            // use of this is to handle load exceptions when instantiating types.
            var filter = context.TestObject as ITestCaseFilter;

            if (filter != null)
            {
                filter.RunTest(context, next);
                adapt.AfterExecuting(context);
                CompleteResult();
                return;
            }

            try {
                var effectiveTimeout = _opts.Timeout.GetValueOrDefault(
                    context.TestRunnerOptions.TestTimeout.GetValueOrDefault()
                    );
                context.RunTestWithTimeout(_testFunc, effectiveTimeout);
                CompleteResult();

                next(context);
            } finally {
                adapt.AfterExecuting(context);
            }
        }