protected internal override TestResult RunImpl(ITestCommand rootTestCommand, Model.Tree.TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount)) { // Note: We do not check options.SkipTestExecution here because we want to build up // the tree of data-driven test steps. So we actually check it later on in the // PatternTestExecutor. This is different from framework adapters // at this time (because they do not generally support dynamically generated data-driven tests). Sandbox sandbox = new Sandbox(); EventHandler canceledHandler = delegate { sandbox.Abort(TestOutcome.Canceled, "The user canceled the test run."); }; try { progressMonitor.Canceled += canceledHandler; TestAssemblyExecutionParameters.Reset(); PatternTestExecutor executor = new PatternTestExecutor(options, progressMonitor, formatter, converter, environmentManager); // Inlined to minimize stack depth. var action = executor.CreateActionToRunTest(rootTestCommand, parentTestStep, sandbox, null); action.Run(); return(action.Result); } finally { progressMonitor.Canceled -= canceledHandler; sandbox.Dispose(); } } }
/// <summary> /// Applies semantic actions to the assembly-level test to estalish its runtime behavior. /// </summary> /// <remarks> /// <para> /// This method is called after <see cref="InitializeAssemblyTest" />. /// </para> /// <para> /// The default behavior for a <see cref="TestAssemblyPatternAttribute" /> /// is to configure the test actions as follows: /// <list type="bullet"> /// <item><see cref="PatternTestActions.InitializeTestChain" />: Reset the <see cref="TestAssemblyExecutionParameters" /> /// to defaults.</item> /// </list> /// </para> /// <para> /// You can override this method to change the semantics as required. /// </para> /// </remarks> /// <param name="testBuilder">The test builder.</param> /// <param name="assembly">The assembly.</param> protected virtual void SetTestSemantics(ITestBuilder testBuilder, IAssemblyInfo assembly) { testBuilder.TestActions.InitializeTestChain.After( delegate(PatternTestState testInstanceState) { TestAssemblyExecutionParameters.Reset(); }); }