private TestLauncherResult RunWithRuntime() { bool wasCanceled = false; ITestProjectManager testProjectManager = RuntimeAccessor.ServiceLocator.Resolve <ITestProjectManager>(); TestProject consolidatedTestProject = ConsolidateTestProject(testProjectManager, ref wasCanceled); if (wasCanceled) { return(CreateResult(ResultCode.Canceled, testProject)); } if (consolidatedTestProject == null) { return(CreateResult(ResultCode.InvalidArguments, testProject)); } if (consolidatedTestProject.TestPackage.Files.Count == 0) { logger.Log(LogSeverity.Warning, "No test files to execute!"); return(CreateResult(ResultCode.NoTests, consolidatedTestProject)); } IReportManager reportManager = RuntimeAccessor.ServiceLocator.Resolve <IReportManager>(); if (!ValidateReportFormats(reportManager, consolidatedTestProject)) { return(CreateResult(ResultCode.InvalidArguments, consolidatedTestProject)); } ITestRunnerManager testRunnerManager = RuntimeAccessor.ServiceLocator.Resolve <ITestRunnerManager>(); ITestRunnerFactory testRunnerFactory = testRunnerManager.GetFactory(consolidatedTestProject.TestRunnerFactoryName); if (testRunnerFactory == null) { logger.Log(LogSeverity.Error, String.Format("Unrecognized test runner factory name: '{0}'.", consolidatedTestProject.TestRunnerFactoryName)); return(CreateResult(ResultCode.InvalidArguments, consolidatedTestProject)); } ITestRunner runner = testRunnerFactory.CreateTestRunner(); var result = new TestLauncherResult(new Report { TestPackage = new TestPackageData(TestProject.TestPackage) }); try { DoRegisterExtensions(runner, consolidatedTestProject); DoInitialize(runner, ref wasCanceled); if (!wasCanceled) { result = RunWithInitializedRunner(runner, consolidatedTestProject, reportManager); } } finally { DoDispose(runner, ref wasCanceled); } if (wasCanceled) { result.SetResultCode(ResultCode.Canceled); } return(result); }