Ejemplo n.º 1
0
        public static async Task <IEnumerable <TestCase> > DiscoverTestsAsync(this IVsTestConsoleWrapper wrapper, string assemblyPath)
        {
            var handler = new TestDiscoveryEventsHandler();

            wrapper.DiscoverTests(new[] { assemblyPath }, GetRunSettingsXml(assemblyPath), handler);
            return(await handler.Task.ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        public (IDictionary <Guid, VsTestDescription>, TestSet) DiscoverTests(string runSettings)
        {
            if (_vsTests != null)
            {
                return(_vsTests, _tests);
            }
            using (var waitHandle = new AutoResetEvent(false))
            {
                var handler             = new DiscoveryEventHandler(waitHandle, _messages);
                var generateRunSettings = GenerateRunSettings(null, false, false, null);
                _vsTestConsole.DiscoverTests(_sources, runSettings ?? generateRunSettings, handler);

                waitHandle.WaitOne();
                if (handler.Aborted)
                {
                    _logger.LogError($"{RunnerId}: Test discovery has been aborted!");
                }

                _vsTests = new Dictionary <Guid, VsTestDescription>(handler.DiscoveredTestCases.Count);
                foreach (var testCase in handler.DiscoveredTestCases)
                {
                    if (!_vsTests.ContainsKey(testCase.Id))
                    {
                        _vsTests[testCase.Id] = new VsTestDescription(testCase);
                    }

                    _vsTests[testCase.Id].AddSubCase();
                }
                DetectTestFramework(_vsTests.Values);
            }

            _tests.RegisterTests(_vsTests.Values.Select(t => t.Description));
            return(_vsTests, _tests);
        }
Ejemplo n.º 3
0
        static IEnumerable <TestCase> DiscoverTests(IEnumerable <string> sources, IVsTestConsoleWrapper consoleWrapper)
        {
            var waitHandle = new AutoResetEvent(false);
            var handler    = new DiscoveryEventHandler(waitHandle);

            consoleWrapper.DiscoverTests(sources, DefaultRunSettings, handler);

            waitHandle.WaitOne();

            return(handler.DiscoveredTestCases);
        }
Ejemplo n.º 4
0
        public IEnumerable <TestCase> DiscoverTests(string runSettings = null)
        {
            var waitHandle = new AutoResetEvent(false);
            var handler    = new DiscoveryEventHandler(waitHandle, _messages);

            _vsTestConsole.DiscoverTests(_sources, runSettings ?? GenerateRunSettings(0), handler);

            waitHandle.WaitOne();

            return(handler.DiscoveredTestCases);
        }
Ejemplo n.º 5
0
        public void DiscoverTests(string runSettings = null)
        {
            var waitHandle = new AutoResetEvent(false);
            var handler    = new DiscoveryEventHandler(waitHandle, _messages);

            _vsTestConsole.DiscoverTests(_sources, runSettings ?? GenerateRunSettings(0), handler);

            waitHandle.WaitOne();

            _testCasesDiscovered = handler.DiscoveredTestCases.Count;
        }
Ejemplo n.º 6
0
        public ICollection <TestCase> DiscoverTests(string runSettings = null)
        {
            if (_discoveredTests == null)
            {
                using (var waitHandle = new AutoResetEvent(false))
                {
                    var handler             = new DiscoveryEventHandler(waitHandle, _messages);
                    var generateRunSettings = GenerateRunSettings(null, false);
                    _vsTestConsole.DiscoverTests(_sources, runSettings ?? generateRunSettings, handler);

                    waitHandle.WaitOne();
                    if (handler.Aborted)
                    {
                        Logger.LogError($"Runner {_id}: Test discovery has been aborted!");
                    }

                    SetListOfTests(handler.DiscoveredTestCases);
                }
            }

            return(_discoveredTests);
        }
Ejemplo n.º 7
0
        public ICollection <TestCase> DiscoverTests(string runSettings = null)
        {
            if (_discoveredTests != null)
            {
                return(_discoveredTests);
            }
            using (var waitHandle = new AutoResetEvent(false))
            {
                var handler             = new DiscoveryEventHandler(waitHandle, _messages);
                var generateRunSettings = GenerateRunSettings(null, false, false, null);
                _vsTestConsole.DiscoverTests(_sources, runSettings ?? generateRunSettings, handler);

                waitHandle.WaitOne();
                if (handler.Aborted)
                {
                    _logger.LogError($"{RunnerId}: Test discovery has been aborted!");
                }

                _discoveredTests = handler.DiscoveredTestCases;
                DetectTestFramework(handler.DiscoveredTestCases);
            }

            return(_discoveredTests);
        }