Ejemplo n.º 1
0
        public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger messageLogger,
                                  ITestCaseDiscoverySink discoverySink)
        {
            var settingsProvider =
                discoveryContext.RunSettings.GetSettings(VSTestSettings.SettingsName) as VSTestSettingsService;
            var settings = settingsProvider != null && settingsProvider.Settings != null
                               ? settingsProvider.Settings
                               : new VSTestSettings() {WorkingDirectory = @"C:\Source"};

            VSLogger logger = new VSLogger(messageLogger);

            foreach (var source in sources)
            {
                logger.Information(string.Format("Beginning test discovery on {0}", source));
                GTestExtractor extractor = new GTestExtractor(false);
                ITestSuite suite = extractor.ExtractFrom(source);

                foreach (var testCase in suite.TestCases)
                {
                    foreach (var test in testCase.Tests)
                    {
                        logger.Information(string.Format("Found test {0}", test.FullyQualifiedName));
                        discoverySink.SendTestCase(test.ToVSTest());

                        System.Threading.Thread.Sleep(0);
                    }
                }

                //ProcessStartInfo listTestsInfo = new ProcessStartInfo();
                //listTestsInfo.FileName = source;
                //listTestsInfo.Arguments = "--gtest_list_tests";
                //listTestsInfo.UseShellExecute = false;
                //listTestsInfo.CreateNoWindow = true;
                //listTestsInfo.RedirectStandardOutput = true;

                //Process listTestsProc = new Process();
                //listTestsProc.StartInfo = listTestsInfo;

                //logger.SendMessage(TestMessageLevel.Informational, string.Format("Beginning test discovery on {0}", source));
                //listTestsProc.Start();

                //listTestsProc.WaitForExit(5000);

                //ParseTests(listTestsProc.StandardOutput, discoverySink, logger, source);
            }
        }
Ejemplo n.º 2
0
        public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            var settingsProvider =
                runContext.RunSettings.GetSettings(VSTestSettings.SettingsName) as VSTestSettingsService;

            VSTestSettings settings;
            if (settingsProvider != null)
            {
                frameworkHandle.SendMessage(TestMessageLevel.Informational, "Found settings.");
                settings = settingsProvider.Settings;
            }
            else
            {
                frameworkHandle.SendMessage(TestMessageLevel.Informational, "No settings found. Using defaults.");
                settings = new VSTestSettings();
            }

            frameworkHandle.SendMessage(TestMessageLevel.Informational, settings.WorkingDirectory);

            _frameworkHandle = frameworkHandle;

            ITestLogger logger = new VSLogger(frameworkHandle);

            GTestConverter converter = new GTestConverter();
            IEnumerable<ITestSuite> suites = converter.ConvertToGTest(tests.ToArray(), logger);

            foreach (var suite in suites)
            {
                logger.Information(string.Format("Processing suite {0}...", suite.RunTarget));
                VSTracker tracker = new VSTracker(frameworkHandle, suite);
                GTestRunner runner = new GTestRunner(logger, false);

                runner.TestCompleted += tracker.TestCompleted;
                logger.Information(string.Format("Running suite {0}...", suite.RunTarget));
                runner.Run(suite);
            }
        }
Ejemplo n.º 3
0
        public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            VSLogger logger = new VSLogger(frameworkHandle);

            foreach (var source in sources)
            {
                logger.Information(string.Format("Attempting to run tests in {0}", source));

                GTestExtractor extractor = new GTestExtractor(false);
                ITestSuite suite = extractor.ExtractFrom(source);

                VSTracker tracker = new VSTracker(frameworkHandle, suite);
                GTestRunner runner = new GTestRunner(logger, false);
                runner.TestCompleted += tracker.TestCompleted;

                runner.Run(suite);
            }
        }