Exemplo n.º 1
0
        private void TryRunTests(IEnumerable <VsTestCase> vsTestCasesToRun, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            var stopwatch = StartStopWatchAndInitEnvironment(runContext, frameworkHandle);

            if (!AbleToRun(runContext))
            {
                return;
            }

            var           vsTestCasesToRunAsArray = vsTestCasesToRun as VsTestCase[] ?? vsTestCasesToRun.ToArray();
            ISet <string> allTraitNames           = GetAllTraitNames(vsTestCasesToRunAsArray.Select(tc => tc.ToTestCase()));
            var           filter = new TestCaseFilter(runContext, allTraitNames, _logger);

            vsTestCasesToRun = filter.Filter(vsTestCasesToRunAsArray);

            ICollection <TestCase> testCasesToRun = vsTestCasesToRun.Select(tc => tc.ToTestCase()).ToArray();

            DoRunTests(testCasesToRun, runContext, frameworkHandle);

            stopwatch.Stop();
            _logger.LogInfo(String.Format(Resources.TestExecutionCompleted, stopwatch.Elapsed));
        }
Exemplo n.º 2
0
        public void RunTests(IEnumerable <VsTestCase> vsTestCasesToRun, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            try
            {
                InitOrRefreshTestEnvironment(runContext.RunSettings, frameworkHandle);

                var           vsTestCasesToRunAsArray = vsTestCasesToRun as VsTestCase[] ?? vsTestCasesToRun.ToArray();
                ISet <string> allTraitNames           = GetAllTraitNames(vsTestCasesToRunAsArray.Select(DataConversionExtensions.ToTestCase));
                var           filter = new TestCaseFilter(runContext, allTraitNames, _testEnvironment);
                vsTestCasesToRun = filter.Filter(vsTestCasesToRunAsArray);

                IEnumerable <TestCase> allTestCasesInExecutables =
                    GetAllTestCasesInExecutables(vsTestCasesToRun.Select(tc => tc.Source).Distinct());

                IEnumerable <TestCase> testCasesToRun = vsTestCasesToRun.Select(DataConversionExtensions.ToTestCase);
                DoRunTests(allTestCasesInExecutables, testCasesToRun, runContext, frameworkHandle);
            }
            catch (Exception e)
            {
                _testEnvironment.LogError("Exception while running tests: " + e);
            }
        }
Exemplo n.º 3
0
        public void RunTests(IEnumerable <string> executables, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            try
            {
                InitOrRefreshTestEnvironment(runContext.RunSettings, frameworkHandle);

                IList <TestCase> allTestCasesInExecutables = GetAllTestCasesInExecutables(executables).ToList();

                ISet <string>     allTraitNames    = GetAllTraitNames(allTestCasesInExecutables);
                var               filter           = new TestCaseFilter(runContext, allTraitNames, _testEnvironment);
                List <VsTestCase> vsTestCasesToRun =
                    filter.Filter(allTestCasesInExecutables.Select(DataConversionExtensions.ToVsTestCase)).ToList();
                IEnumerable <TestCase> testCasesToRun =
                    allTestCasesInExecutables.Where(tc => vsTestCasesToRun.Any(vtc => tc.FullyQualifiedName == vtc.FullyQualifiedName)).ToList();

                DoRunTests(allTestCasesInExecutables, testCasesToRun, runContext, frameworkHandle);
            }
            catch (Exception e)
            {
                _testEnvironment.LogError("Exception while running tests: " + e);
            }
        }
Exemplo n.º 4
0
        private void TryRunTests(IEnumerable <string> executables, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            InitOrRefreshEnvironment(runContext.RunSettings, frameworkHandle);
            _logger.LogInfo("Google Test Adapter: Test execution starting...");
            _logger.DebugInfo($"Solution settings: {_settings}");

            IList <TestCase> allTestCasesInExecutables = GetAllTestCasesInExecutables(executables).ToList();

            ISet <string>     allTraitNames    = GetAllTraitNames(allTestCasesInExecutables);
            var               filter           = new TestCaseFilter(runContext, allTraitNames, _logger);
            List <VsTestCase> vsTestCasesToRun =
                filter.Filter(allTestCasesInExecutables.Select(DataConversionExtensions.ToVsTestCase)).ToList();
            ICollection <TestCase> testCasesToRun =
                allTestCasesInExecutables.Where(
                    tc => vsTestCasesToRun.Any(vtc => tc.FullyQualifiedName == vtc.FullyQualifiedName)).ToArray();

            DoRunTests(allTestCasesInExecutables, testCasesToRun, runContext, frameworkHandle);

            stopwatch.Stop();
            _logger.LogInfo($"Google Test execution completed, overall duration: {stopwatch.Elapsed}.");
        }
Exemplo n.º 5
0
        private void TryRunTests(IEnumerable <string> executables, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            var stopwatch = StartStopWatchAndInitEnvironment(runContext, frameworkHandle);

            if (!AbleToRun(runContext))
            {
                return;
            }

            IList <TestCase> allTestCasesInExecutables = GetAllTestCasesInExecutables(executables).ToList();

            ISet <string>     allTraitNames    = GetAllTraitNames(allTestCasesInExecutables);
            var               filter           = new TestCaseFilter(runContext, allTraitNames, _logger);
            List <VsTestCase> vsTestCasesToRun =
                filter.Filter(allTestCasesInExecutables.Select(tc => tc.ToVsTestCase())).ToList();
            ICollection <TestCase> testCasesToRun =
                allTestCasesInExecutables.Where(
                    tc => vsTestCasesToRun.Any(vtc => tc.FullyQualifiedName == vtc.FullyQualifiedName)).ToArray();

            DoRunTests(testCasesToRun, runContext, frameworkHandle);

            stopwatch.Stop();
            _logger.LogInfo(String.Format(Resources.TestExecutionCompleted, stopwatch.Elapsed));
        }
Exemplo n.º 6
0
        private void TryRunTests(IEnumerable <VsTestCase> vsTestCasesToRun, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            InitOrRefreshEnvironment(runContext.RunSettings, frameworkHandle);
            _logger.LogInfo("Google Test Adapter: Test execution starting...");
            _logger.DebugInfo($"Solution settings: {_settings}");

            var           vsTestCasesToRunAsArray = vsTestCasesToRun as VsTestCase[] ?? vsTestCasesToRun.ToArray();
            ISet <string> allTraitNames           = GetAllTraitNames(vsTestCasesToRunAsArray.Select(DataConversionExtensions.ToTestCase));
            var           filter = new TestCaseFilter(runContext, allTraitNames, _logger);

            vsTestCasesToRun = filter.Filter(vsTestCasesToRunAsArray);

            IEnumerable <TestCase> allTestCasesInExecutables =
                GetAllTestCasesInExecutables(vsTestCasesToRun.Select(tc => tc.Source).Distinct());

            ICollection <TestCase> testCasesToRun = vsTestCasesToRun.Select(DataConversionExtensions.ToTestCase).ToArray();

            DoRunTests(allTestCasesInExecutables, testCasesToRun, runContext, frameworkHandle);

            stopwatch.Stop();
            _logger.LogInfo($"Google Test execution completed, overall duration: {stopwatch.Elapsed}.");
        }