/// <summary> /// Add the extra common things here that we can't do in the BaseTestRunner without adding too much coupling. /// </summary> /// <param name="runner">What runner to use</param> /// <param name="specificTestAction">What test action to take with the runner </param> private void StandardRunTestBehavior(BaseTestRunner runner, RunTestSelectorAction specificTestAction) { bool buildPassed = BuildActiveProject(); if (buildPassed) { try { EnvDTE.Project activeProject = GetActiveProject(); string assemblyPath = GetAssemblyPath(activeProject); string assemblyName = GetAssemblyName(activeProject); CodeRush.Windows.Active.DTE.StatusBar.Text = kTestingStartedMessage; BaseTestRunner.StandardRunTestBehavior(runner, runner_TestsStarting, runner_TestComplete, runner_AllTestsComplete, assemblyPath, assemblyName, specificTestAction); } catch (System.Exception ex) { WriteToTestPane("-->RedGreen Program Failure<--"); WriteToTestPane(ex.Message); WriteToTestPane(ex.StackTrace); throw; } } else { ShowBuildOutputWindow(); } }
/// <summary> /// Handle wiring up the events and running everything in a try catch block. /// </summary> /// <param name="runner">Which test runner to use when launching tests </param> /// <param name="startingHandler">method to wire up to start event</param> /// <param name="testCompleteHandler">method to recieve test complete event</param> /// <param name="allCompleteHandler">method to recieve all tests complete event</param> /// <param name="assemblyPath">File path to assembly containing tests </param> /// <param name="assemblyName">Full name of assembly containing tests </param> /// <param name="specificTestAction">Delegate that will call the correct testRunner method and do any other tasks associated with testing</param> public static void StandardRunTestBehavior(BaseTestRunner runner, TestsStartingHandler startingHandler, TestCompleteEventHandler testCompleteHandler, AllTestsCompleteEventHandler allCompleteHandler, string assemblyPath, string assemblyName, RunTestSelectorAction specificTestAction) { try { runner.TestsStarting += startingHandler; runner.TestComplete += testCompleteHandler; runner.AllTestsComplete += allCompleteHandler; specificTestAction(runner, assemblyPath, assemblyName); } finally { runner.TestsStarting -= startingHandler; runner.TestComplete -= testCompleteHandler; runner.AllTestsComplete -= allCompleteHandler; } }