private void DoRunTests(ICollection <TestCase> testCasesToRun, IRunContext runContext, IFrameworkHandle frameworkHandle) { if (testCasesToRun.Count == 0) { return; } bool isRunningInsideVisualStudio = !string.IsNullOrEmpty(runContext.SolutionDirectory); var reporter = new VsTestFrameworkReporter(frameworkHandle, isRunningInsideVisualStudio, _logger); var debuggerAttacher = _debuggerAttacher ?? new MessageBasedDebuggerAttacher(_settings.DebuggingNamedPipeId, _logger); var processExecutorFactory = new DebuggedProcessExecutorFactory(frameworkHandle, debuggerAttacher); var exitCodeTestsAggregator = new ExitCodeTestsAggregator(); var exitCodeTestsReporter = new ExitCodeTestsReporter(reporter, exitCodeTestsAggregator, _settings, _logger); lock (_lock) { if (_canceled) { return; } _executor = new GoogleTestExecutor(_logger, _settings, processExecutorFactory, exitCodeTestsReporter); } _executor.RunTests(testCasesToRun, reporter, runContext.IsBeingDebugged); reporter.AllTestsFinished(); }
private void DoRunTests(ICollection <TestCase> testCasesToRun, IRunContext runContext, IFrameworkHandle frameworkHandle) { if (testCasesToRun.Count == 0) { return; } bool isRunningInsideVisualStudio = !string.IsNullOrEmpty(runContext.SolutionDirectory); var reporter = new VsTestFrameworkReporter(frameworkHandle, isRunningInsideVisualStudio, _logger); var launcher = new DebuggedProcessLauncher(frameworkHandle); ProcessExecutor processExecutor = null; if (_settings.UseNewTestExecutionFramework) { IDebuggerAttacher debuggerAttacher = null; if (runContext.IsBeingDebugged) { debuggerAttacher = new MessageBasedDebuggerAttacher(_settings.DebuggingNamedPipeId, _logger); } processExecutor = new ProcessExecutor(debuggerAttacher, _logger); } lock (_lock) { if (_canceled) { return; } _executor = new GoogleTestExecutor(_logger, _settings); } _executor.RunTests(testCasesToRun, reporter, launcher, runContext.IsBeingDebugged, runContext.SolutionDirectory, processExecutor); reporter.AllTestsFinished(); }
public void DiscoverTests(IEnumerable <string> executables, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { Stopwatch stopwatch = Stopwatch.StartNew(); if (_settings == null || _settings.GetType() == typeof(SettingsWrapper)) // check whether we have a mock { CommonFunctions.CreateEnvironment(discoveryContext.RunSettings, logger, out _logger, out _settings); _discoverer = new GoogleTestDiscoverer(_logger, _settings); } _logger.LogInfo("Google Test Adapter: Test discovery starting..."); _logger.DebugInfo($"Solution settings: {_settings}"); try { var reporter = new VsTestFrameworkReporter(discoverySink); _discoverer.DiscoverTests(executables, reporter); stopwatch.Stop(); _logger.LogInfo($"Test discovery completed, overall duration: {stopwatch.Elapsed}"); } catch (Exception e) { _logger.LogError($"Exception while discovering tests: {e}"); } CommonFunctions.ReportErrors(_logger, "test discovery", _settings.DebugMode); }
private void DoRunTests( IEnumerable <TestCase> allTestCasesInExecutables, IEnumerable <TestCase> testCasesToRun, IRunContext runContext, IFrameworkHandle frameworkHandle) { bool isRunningInsideVisualStudio = !string.IsNullOrEmpty(runContext.SolutionDirectory); var reporter = new VsTestFrameworkReporter(frameworkHandle, isRunningInsideVisualStudio); var launcher = new DebuggedProcessLauncher(frameworkHandle); _executor = new GoogleTestExecutor(_testEnvironment); _executor.RunTests(allTestCasesInExecutables, testCasesToRun, reporter, launcher, runContext.IsBeingDebugged, runContext.SolutionDirectory); reporter.AllTestsFinished(); }
private void DoRunTests( IEnumerable <TestCase> allTestCasesInExecutables, ICollection <TestCase> testCasesToRun, IRunContext runContext, IFrameworkHandle frameworkHandle, Stopwatch stopwatch) { bool isRunningInsideVisualStudio = !string.IsNullOrEmpty(runContext.SolutionDirectory); var reporter = new VsTestFrameworkReporter(frameworkHandle, isRunningInsideVisualStudio); var launcher = new DebuggedProcessLauncher(frameworkHandle); _executor = new GoogleTestExecutor(_testEnvironment); _executor.RunTests(allTestCasesInExecutables, testCasesToRun, reporter, launcher, runContext.IsBeingDebugged, runContext.SolutionDirectory); reporter.AllTestsFinished(); stopwatch.Stop(); _testEnvironment.LogInfo($"Google Test execution completed, overall duration: {stopwatch.Elapsed}."); }
public void DiscoverTests(IEnumerable <string> executables, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { if (_testEnvironment == null || _testEnvironment.Options.GetType() == typeof(SettingsWrapper)) // check whether we have a mock { _testEnvironment = TestExecutor.CreateTestEnvironment(discoveryContext.RunSettings, logger); _discoverer = new GoogleTestDiscoverer(_testEnvironment); } try { VsTestFrameworkReporter reporter = new VsTestFrameworkReporter(discoverySink); _discoverer.DiscoverTests(executables, reporter); } catch (Exception e) { _testEnvironment.LogError("Exception while discovering tests: " + e); } }
public void DiscoverTests(IEnumerable <string> executables, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { Stopwatch stopwatch = Stopwatch.StartNew(); if (_settings == null || _settings.GetType() == typeof(SettingsWrapper)) // check whether we have a mock { CommonFunctions.CreateEnvironment(discoveryContext.RunSettings, logger, out _logger, out _settings); } _discoverer = new GoogleTestDiscoverer(_logger, _settings); if (!IsSupportedVisualStudioVersion()) { return; } CommonFunctions.LogVisualStudioVersion(_logger); _logger.LogInfo(Strings.Instance.TestDiscoveryStarting); _logger.DebugInfo($"Solution settings: {_settings}"); if (_settings.SkipOriginCheck) { _logger.LogWarning($"Option '{SettingsWrapper.OptionSkipOriginCheck}' is true - this might impose a security risk to your system"); } try { var reporter = new VsTestFrameworkReporter(discoverySink, _logger); _discoverer.DiscoverTests(executables, reporter); stopwatch.Stop(); _logger.LogInfo($"Test discovery completed, overall duration: {stopwatch.Elapsed}"); } catch (Exception e) { _logger.LogError($"Exception while discovering tests: {e}"); } CommonFunctions.ReportErrors(_logger, "test discovery", _settings.OutputMode, _settings.SummaryMode); }
private void DoRunTests( IEnumerable <TestCase> allTestCasesInExecutables, ICollection <TestCase> testCasesToRun, IRunContext runContext, IFrameworkHandle frameworkHandle) { bool isRunningInsideVisualStudio = !string.IsNullOrEmpty(runContext.SolutionDirectory); var reporter = new VsTestFrameworkReporter(frameworkHandle, isRunningInsideVisualStudio); var launcher = new DebuggedProcessLauncher(frameworkHandle); ProcessExecutor processExecutor = null; if (_settings.UseNewTestExecutionFramework) { IDebuggerAttacher debuggerAttacher = null; if (runContext.IsBeingDebugged) { debuggerAttacher = new VsDebuggerAttacher(_logger, _settings.VisualStudioProcessId); } processExecutor = new ProcessExecutor(debuggerAttacher, _logger); } _executor = new GoogleTestExecutor(_logger, _settings); _executor.RunTests(allTestCasesInExecutables, testCasesToRun, reporter, launcher, runContext.IsBeingDebugged, runContext.SolutionDirectory, processExecutor); reporter.AllTestsFinished(); }
public void DiscoverTests(IEnumerable <string> executables, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { Stopwatch stopwatch = Stopwatch.StartNew(); if (_settings == null || _settings.GetType() == typeof(SettingsWrapper)) // check whether we have a mock { CommonFunctions.CreateEnvironment(discoveryContext.RunSettings, logger, out _logger, out _settings); _discoverer = new GoogleTestDiscoverer(_logger, _settings); } if (!IsSupportedVisualStudioVersion()) { return; } CommonFunctions.LogVisualStudioVersion(_logger); _logger.LogInfo(Common.Resources.TestDiscoveryStarting); _logger.DebugInfo(String.Format(Resources.Settings, _settings)); try { var reporter = new VsTestFrameworkReporter(discoverySink, _logger); _discoverer.DiscoverTests(executables, reporter); stopwatch.Stop(); _logger.LogInfo(String.Format(Resources.TestDiscoveryCompleted, stopwatch.Elapsed)); } catch (Exception e) { _logger.LogError(String.Format(Resources.TestDiscoveryExceptionError, e)); } CommonFunctions.ReportErrors(_logger, TestPhase.TestDiscovery, _settings.DebugMode); }
public void DiscoverTests(IEnumerable <string> executables, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { ILogger loggerAdapter = new VsTestFrameworkLogger(logger); if (TestEnvironment == null || TestEnvironment.Options.GetType() == typeof(Options)) // check whether we have a mock { var settingsProvider = discoveryContext.RunSettings.GetSettings(GoogleTestConstants.SettingsName) as RunSettingsProvider; RunSettings ourRunSettings = settingsProvider != null ? settingsProvider.Settings : new RunSettings(); TestEnvironment = new TestEnvironment(new Options(ourRunSettings, loggerAdapter), loggerAdapter); Discoverer = new GoogleTestDiscoverer(TestEnvironment); } try { VsTestFrameworkReporter reporter = new VsTestFrameworkReporter(discoverySink); Discoverer.DiscoverTests(executables, reporter); } catch (Exception e) { TestEnvironment.LogError("Exception while discovering tests: " + e); } }