Example #1
0
        public void RunTests(IEnumerable <string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            if (sources == null)
            {
                throw new ArgumentNullException(nameof(sources));
            }

            if (runContext == null)
            {
                throw new ArgumentNullException(nameof(runContext));
            }

            if (frameworkHandle == null)
            {
                throw new ArgumentNullException(nameof(frameworkHandle));
            }

            _cancelRequested.Reset();

            var sourceToProjSettings = RunSettingsUtil.GetSourceToProjSettings(runContext.RunSettings, filterType: TestFrameworkType.UnitTest);
            var testColletion        = new TestCollection();

            foreach (var testGroup in sources.GroupBy(x => sourceToProjSettings[x]))
            {
                var settings = testGroup.Key;

                try {
                    var discovery = DiscovererFactory.GetDiscoverer(settings);
                    discovery.DiscoverTests(testGroup, frameworkHandle, testColletion);
                } catch (Exception ex) {
                    frameworkHandle.SendMessage(TestMessageLevel.Error, ex.Message);
                }

                if (_cancelRequested.WaitOne(0))
                {
                    return;
                }
            }

            RunTestCases(testColletion.Tests, runContext, frameworkHandle);
        }
Example #2
0
        private void DiscoverTestGroup(
            IGrouping <PythonProjectSettings, string> testGroup,
            IDiscoveryContext discoveryContext,
            IMessageLogger logger,
            ITestCaseDiscoverySink discoverySink
            )
        {
            PythonProjectSettings settings = testGroup.Key;

            if (settings == null || settings.TestFramework != _frameworkType)
            {
                return;
            }

            try {
                var discovery = DiscovererFactory.GetDiscoverer(settings);
                discovery.DiscoverTests(testGroup, logger, discoverySink);
            } catch (Exception ex) {
                logger.SendMessage(TestMessageLevel.Error, ex.Message);
            }
        }