コード例 #1
0
        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);
            }

        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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}");

            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.DebugMode);
        }
コード例 #4
0
 public TestDiscoverer(ILogger logger, SettingsWrapper settings)
 {
     _settings   = settings;
     _logger     = logger;
     _discoverer = new GoogleTestDiscoverer(_logger, _settings);
 }
コード例 #5
0
        private IEnumerable<TestCase> GetAllTestCasesInExecutables(IEnumerable<string> executables)
        {
            var allTestCasesInExecutables = new List<TestCase>();

            var discoverer = new GoogleTestDiscoverer(_testEnvironment);
            foreach (string executable in executables.OrderBy(e => e))
            {
                if (_canceled)
                {
                    allTestCasesInExecutables.Clear();
                    break;
                }

                allTestCasesInExecutables.AddRange(discoverer.GetTestsFromExecutable(executable));
            }

            return allTestCasesInExecutables;
        }
コード例 #6
0
 public TestDiscoverer(TestEnvironment testEnvironment)
 {
     _testEnvironment = testEnvironment;
     _discoverer      = new GoogleTestDiscoverer(_testEnvironment);
 }
コード例 #7
0
 public TestDiscoverer(TestEnvironment testEnvironment)
 {
     _testEnvironment = testEnvironment;
     _discoverer = new GoogleTestDiscoverer(_testEnvironment);
 }