public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { ChutzpahTracer.TraceInformation("Begin Test Adapter Run Tests"); var settingsProvider = runContext.RunSettings.GetSettings(AdapterConstants.SettingsName) as ChutzpahAdapterSettingsProvider; var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings(); ChutzpahTracingHelper.Toggle(settings.EnabledTracing); var testOptions = new TestOptions { TestLaunchMode = runContext.IsBeingDebugged ? TestLaunchMode.Custom: settings.OpenInBrowser ? TestLaunchMode.FullBrowser: TestLaunchMode.HeadlessBrowser, CustomTestLauncher = runContext.IsBeingDebugged ? new VsDebuggerTestLauncher() : null, MaxDegreeOfParallelism = runContext.IsBeingDebugged ? 1 : settings.MaxDegreeOfParallelism, ChutzpahSettingsFileEnvironments = new ChutzpahSettingsFileEnvironments(settings.ChutzpahSettingsFileEnvironments) }; testOptions.CoverageOptions.Enabled = runContext.IsDataCollectionEnabled; var callback = new ParallelRunnerCallbackAdapter(new ExecutionCallback(frameworkHandle, runContext)); testRunner.RunTests(sources, testOptions, callback); ChutzpahTracer.TraceInformation("End Test Adapter Run Tests"); }
public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { var settingsProvider = runContext.RunSettings.GetSettings(ChutzpahAdapterSettings.SettingsName) as ChutzpahAdapterSettingsService; var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings(); var testOptions = new TestOptions { TestFileTimeoutMilliseconds = settings.TimeoutMilliseconds, TestingMode = settings.TestingMode, MaxDegreeOfParallelism = settings.MaxDegreeOfParallelism, }; testOptions.CoverageOptions.Enabled = runContext.IsDataCollectionEnabled; var callback = new ParallelRunnerCallbackAdapter(new ExecutionCallback(frameworkHandle, runContext)); testRunner.RunTests(sources, testOptions, callback); }
static int RunTests(CommandLine commandLine) { var testRunner = TestRunner.Create(debugEnabled: commandLine.Debug); if (commandLine.Trace) { ChutzpahTracer.AddFileListener(); } Console.WriteLine(); TestCaseSummary testResultsSummary = null; try { var callback = commandLine.TeamCity ? (ITestMethodRunnerCallback)new TeamCityConsoleRunnerCallback() : new StandardConsoleRunnerCallback(commandLine.Silent, commandLine.VsOutput, commandLine.ShowFailureReport, commandLine.FailOnError); callback = new ParallelRunnerCallbackAdapter(callback); var testOptions = new TestOptions { TestLaunchMode = commandLine.OpenInBrowser ? TestLaunchMode.FullBrowser : TestLaunchMode.HeadlessBrowser, BrowserName = commandLine.BrowserName, TestFileTimeoutMilliseconds = commandLine.TimeOutMilliseconds, MaxDegreeOfParallelism = commandLine.Parallelism, ChutzpahSettingsFileEnvironments = commandLine.SettingsFileEnvironments, CoverageOptions = new CoverageOptions { Enabled = commandLine.Coverage, IncludePatterns = (commandLine.CoverageIncludePatterns ?? "").Split(new[]{','},StringSplitOptions.RemoveEmptyEntries), ExcludePatterns = (commandLine.CoverageExcludePatterns ?? "").Split(new[]{','},StringSplitOptions.RemoveEmptyEntries), IgnorePatterns = (commandLine.CoverageIgnorePatterns ?? "").Split(new[]{','},StringSplitOptions.RemoveEmptyEntries) } }; if (!commandLine.Discovery) { testResultsSummary = testRunner.RunTests(commandLine.Files, testOptions, callback); ProcessTestSummaryTransformers(commandLine, testResultsSummary); } else { Console.WriteLine("Test Discovery"); var tests = testRunner.DiscoverTests(commandLine.Files, testOptions).ToList(); Console.WriteLine("\nDiscovered {0} tests", tests.Count); foreach (var test in tests) { Console.WriteLine("Test '{0}:{1}' from '{2}'", test.ModuleName, test.TestName, test.InputTestFile); } return 0; } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } var failedCount = testResultsSummary.FailedCount; if (commandLine.FailOnError && testResultsSummary.Errors.Any()) { return failedCount > 0 ? failedCount : 1; } return failedCount; }