Exemplo n.º 1
0
        /// <inheritdoc/>
        public async Task RunTestsWithCustomTestHostAsync(
            IEnumerable <TestCase> testCases,
            string runSettings,
            TestPlatformOptions options,
            TestSessionInfo testSessionInfo,
            ITestRunEventsHandler testRunEventsHandler,
            ITestHostLauncher customTestHostLauncher)
        {
            var testCaseList = testCases.ToList();

            this.testPlatformEventSource.TranslationLayerExecutionStart(
                1,
                0,
                testCaseList.Count,
                runSettings ?? string.Empty);

            await this.EnsureInitializedAsync();

            await this.requestSender.StartTestRunWithCustomHostAsync(
                testCaseList,
                runSettings,
                options,
                testSessionInfo,
                testRunEventsHandler,
                customTestHostLauncher);
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public void RunTestsWithCustomTestHost(
            IEnumerable <string> sources,
            string runSettings,
            TestPlatformOptions options,
            TestSessionInfo testSessionInfo,
            ITestRunEventsHandler testRunEventsHandler,
            ITestHostLauncher customTestHostLauncher)
        {
            var sourceList = sources.ToList();

            this.testPlatformEventSource.TranslationLayerExecutionStart(
                1,
                sourceList.Count,
                0,
                runSettings ?? string.Empty);

            this.EnsureInitialized();
            this.requestSender.StartTestRunWithCustomHost(
                sourceList,
                runSettings,
                options,
                testSessionInfo,
                testRunEventsHandler,
                customTestHostLauncher);
        }
 /// <inheritdoc/>
 public void DiscoverTests(IEnumerable <string> sources, string runSettings, TestPlatformOptions options, ITestDiscoveryEventsHandler2 eventHandler)
 {
     if (EqtTrace.IsInfoEnabled)
     {
         EqtTrace.Info("VsTestConsoleRequestSender.DiscoverTests: Starting test discovery.");
     }
     this.SendMessageAndListenAndReportTestCases(sources, runSettings, options, eventHandler);
 }
        /// <inheritdoc/>
        public void RunTests(IEnumerable <TestCase> testCases, string runSettings, TestPlatformOptions options, ITestRunEventsHandler testRunEventsHandler)
        {
            var testCaseList = testCases.ToList();

            this.testPlatformEventSource.TranslationLayerExecutionStart(0, 0, testCaseList.Count, runSettings ?? string.Empty);

            this.EnsureInitialized();
            this.requestSender.StartTestRun(testCaseList, runSettings, options, testRunEventsHandler);
        }
Exemplo n.º 5
0
 /// <inheritdoc/>
 public void StartTestRun(IEnumerable <string> sources, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler)
 {
     this.SendMessageAndListenAndReportTestResults(
         MessageType.TestRunAllSourcesWithDefaultHost,
         new TestRunRequestPayload()
     {
         Sources = sources.ToList(), RunSettings = runSettings, TestCaseFilter = options?.TestCaseFilter
     },
         runEventsHandler,
         null);
 }
Exemplo n.º 6
0
 /// <inheritdoc/>
 public void RunTests(
     IEnumerable <TestCase> testCases,
     string runSettings,
     TestPlatformOptions options,
     ITestRunEventsHandler testRunEventsHandler)
 {
     this.RunTests(
         testCases,
         runSettings,
         options,
         testSessionInfo: null,
         testRunEventsHandler);
 }
Exemplo n.º 7
0
 /// <inheritdoc/>
 public void DiscoverTests(
     IEnumerable <string> sources,
     string discoverySettings,
     TestPlatformOptions options,
     ITestDiscoveryEventsHandler2 discoveryEventsHandler)
 {
     this.DiscoverTests(
         sources,
         discoverySettings,
         options,
         testSessionInfo: null,
         discoveryEventsHandler);
 }
Exemplo n.º 8
0
 /// <inheritdoc/>
 public void DiscoverTests(
     IEnumerable <string> sources,
     string discoverySettings,
     TestPlatformOptions options,
     ITestDiscoveryEventsHandler2 discoveryEventsHandler)
 {
     // TODO (copoiena): Hook into the wrapper and pass session info here.
     this.consoleWrapper.DiscoverTests(
         sources,
         discoverySettings,
         options,
         discoveryEventsHandler);
 }
Exemplo n.º 9
0
 /// <inheritdoc/>
 public async Task RunTestsAsync(
     IEnumerable <string> sources,
     string runSettings,
     TestPlatformOptions options,
     ITestRunEventsHandler testRunEventsHandler)
 {
     await this.consoleWrapper.RunTestsAsync(
         sources,
         runSettings,
         options,
         this.testSessionInfo,
         testRunEventsHandler);
 }
Exemplo n.º 10
0
 /// <inheritdoc/>
 public ITestSession StartTestSession(
     IList <string> sources,
     string runSettings,
     TestPlatformOptions options,
     ITestSessionEventsHandler eventsHandler)
 {
     return(this.StartTestSession(
                sources,
                runSettings,
                options,
                eventsHandler,
                testHostLauncher: null));
 }
Exemplo n.º 11
0
 /// <inheritdoc/>
 public async Task RunTestsAsync(
     IEnumerable <TestCase> testCases,
     string runSettings,
     TestPlatformOptions options,
     ITestRunEventsHandler testRunEventsHandler)
 {
     await this.RunTestsAsync(
         testCases,
         runSettings,
         options,
         testSessionInfo : null,
         testRunEventsHandler);
 }
Exemplo n.º 12
0
 /// <inheritdoc/>
 public void RunTests(
     IEnumerable <string> sources,
     string runSettings,
     TestPlatformOptions options,
     ITestRunEventsHandler testRunEventsHandler)
 {
     this.consoleWrapper.RunTests(
         sources,
         runSettings,
         options,
         this.testSessionInfo,
         testRunEventsHandler);
 }
Exemplo n.º 13
0
 /// <inheritdoc/>
 public async Task <ITestSession> StartTestSessionAsync(
     IList <string> sources,
     string runSettings,
     TestPlatformOptions options,
     ITestSessionEventsHandler eventsHandler)
 {
     return(await this.StartTestSessionAsync(
                sources,
                runSettings,
                options : null,
                eventsHandler,
                testHostLauncher : null).ConfigureAwait(false));
 }
Exemplo n.º 14
0
 /// <inheritdoc/>
 public async Task DiscoverTestsAsync(
     IEnumerable <string> sources,
     string discoverySettings,
     TestPlatformOptions options,
     ITestDiscoveryEventsHandler2 discoveryEventsHandler)
 {
     await this.DiscoverTestsAsync(
         sources,
         discoverySettings,
         options,
         testSessionInfo : null,
         discoveryEventsHandler);
 }
Exemplo n.º 15
0
        /// <inheritdoc/>
        public void RunTests(IEnumerable <string> sources, string runSettings, TestPlatformOptions options, ITestRunEventsHandler testRunEventsHandler)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options), "The test platform options cannot be null.");
            }

            var sourceList = sources.ToList();

            this.testPlatformEventSource.TranslationLayerExecutionStart(0, sourceList.Count, 0, runSettings ?? string.Empty);

            this.EnsureInitialized();
            this.requestSender.StartTestRun(sourceList, runSettings, options, testRunEventsHandler);
        }
Exemplo n.º 16
0
 /// <inheritdoc/>
 public void RunTestsWithCustomTestHost(
     IEnumerable <string> sources,
     string runSettings,
     TestPlatformOptions options,
     ITestRunEventsHandler testRunEventsHandler,
     ITestHostLauncher customTestHostLauncher)
 {
     this.consoleWrapper.RunTestsWithCustomTestHost(
         sources,
         runSettings,
         options,
         this.testSessionInfo,
         testRunEventsHandler,
         customTestHostLauncher);
 }
Exemplo n.º 17
0
 /// <inheritdoc/>
 public async Task RunTestsWithCustomTestHostAsync(
     IEnumerable <string> sources,
     string runSettings,
     TestPlatformOptions options,
     ITestRunEventsHandler testRunEventsHandler,
     ITestHostLauncher customTestHostLauncher)
 {
     await this.RunTestsWithCustomTestHostAsync(
         sources,
         runSettings,
         options,
         testSessionInfo : null,
         testRunEventsHandler,
         customTestHostLauncher);
 }
Exemplo n.º 18
0
 /// <inheritdoc/>
 public async Task RunTestsWithCustomTestHostAsync(
     IEnumerable <TestCase> testCases,
     string runSettings,
     TestPlatformOptions options,
     ITestRunEventsHandler testRunEventsHandler,
     ITestHostLauncher customTestHostLauncher)
 {
     await this.consoleWrapper.RunTestsWithCustomTestHostAsync(
         testCases,
         runSettings,
         options,
         this.testSessionInfo,
         testRunEventsHandler,
         customTestHostLauncher);
 }
Exemplo n.º 19
0
 /// <inheritdoc/>
 public void RunTestsWithCustomTestHost(
     IEnumerable <TestCase> testCases,
     string runSettings,
     TestPlatformOptions options,
     ITestRunEventsHandler testRunEventsHandler,
     ITestHostLauncher customTestHostLauncher)
 {
     this.RunTestsWithCustomTestHost(
         testCases,
         runSettings,
         options,
         testSessionInfo: null,
         testRunEventsHandler,
         customTestHostLauncher);
 }
Exemplo n.º 20
0
        /// <inheritdoc/>
        public void StartTestRun(IEnumerable <string> sources, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler)
        {
            if (EqtTrace.IsInfoEnabled)
            {
                EqtTrace.Info("VsTestConsoleRequestSender.StartTestRun: Starting test run.");
            }

            this.SendMessageAndListenAndReportTestResults(
                MessageType.TestRunAllSourcesWithDefaultHost,
                new TestRunRequestPayload()
            {
                Sources = sources.ToList(), RunSettings = runSettings, TestPlatformOptions = options
            },
                runEventsHandler,
                null);
        }
Exemplo n.º 21
0
 /// <inheritdoc/>
 public void DiscoverTests(
     IEnumerable <string> sources,
     string discoverySettings,
     TestPlatformOptions options,
     TestSessionInfo testSessionInfo,
     ITestDiscoveryEventsHandler2 discoveryEventsHandler)
 {
     this.testPlatformEventSource.TranslationLayerDiscoveryStart();
     this.EnsureInitialized();
     // TODO (copoiena): Add session info as a parameter.
     this.requestSender.DiscoverTests(
         sources,
         discoverySettings,
         options,
         discoveryEventsHandler);
 }
Exemplo n.º 22
0
        /// <inheritdoc/>
        public ITestSession StartTestSession(
            IList <string> sources,
            string runSettings,
            TestPlatformOptions options,
            ITestSessionEventsHandler eventsHandler,
            ITestHostLauncher testHostLauncher)
        {
            this.testPlatformEventSource.TranslationLayerStartTestSessionStart();

            this.EnsureInitialized();
            return(new TestSession(
                       this.requestSender.StartTestSession(
                           sources,
                           runSettings,
                           options,
                           eventsHandler,
                           testHostLauncher),
                       this));
        }
Exemplo n.º 23
0
 /// <inheritdoc/>
 public void StartTestRunWithCustomHost(
     IEnumerable <string> sources,
     string runSettings,
     TestPlatformOptions options,
     ITestRunEventsHandler runEventsHandler,
     ITestHostLauncher customHostLauncher)
 {
     this.SendMessageAndListenAndReportTestResults(
         MessageType.GetTestRunnerProcessStartInfoForRunAll,
         new TestRunRequestPayload()
     {
         Sources          = sources.ToList(),
         RunSettings      = runSettings,
         DebuggingEnabled = customHostLauncher.IsDebug,
         TestCaseFilter   = options?.TestCaseFilter
     },
         runEventsHandler,
         customHostLauncher);
 }
Exemplo n.º 24
0
        /// <inheritdoc/>
        public async Task <ITestSession> StartTestSessionAsync(
            IList <string> sources,
            string runSettings,
            TestPlatformOptions options,
            ITestSessionEventsHandler eventsHandler,
            ITestHostLauncher testHostLauncher)
        {
            this.testPlatformEventSource.TranslationLayerStartTestSessionStart();

            await this.EnsureInitializedAsync().ConfigureAwait(false);

            return(new TestSession(
                       await this.requestSender.StartTestSessionAsync(
                           sources,
                           runSettings,
                           options,
                           eventsHandler,
                           testHostLauncher).ConfigureAwait(false),
                       this));
        }
Exemplo n.º 25
0
        /// <inheritdoc/>
        public async Task RunTestsAsync(
            IEnumerable <string> sources,
            string runSettings,
            TestPlatformOptions options,
            TestSessionInfo testSessionInfo,
            ITestRunEventsHandler testRunEventsHandler)
        {
            var sourceList = sources.ToList();

            this.testPlatformEventSource.TranslationLayerExecutionStart(
                0,
                sourceList.Count,
                0,
                runSettings ?? string.Empty);

            await this.EnsureInitializedAsync();

            await this.requestSender.StartTestRunAsync(
                sourceList,
                runSettings,
                options,
                testSessionInfo,
                testRunEventsHandler);
        }
Exemplo n.º 26
0
        /// <inheritdoc/>
        public async Task StartTestRunWithCustomHostAsync(
            IEnumerable <string> sources,
            string runSettings,
            TestPlatformOptions options,
            ITestRunEventsHandler runEventsHandler,
            ITestHostLauncher customHostLauncher)
        {
            if (EqtTrace.IsInfoEnabled)
            {
                EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHostAsync: Starting test run.");
            }

            await this.SendMessageAndListenAndReportTestResultsAsync(
                MessageType.GetTestRunnerProcessStartInfoForRunAll,
                new TestRunRequestPayload()
            {
                Sources             = sources.ToList(),
                RunSettings         = runSettings,
                DebuggingEnabled    = customHostLauncher.IsDebug,
                TestPlatformOptions = options
            },
                runEventsHandler,
                customHostLauncher);
        }
Exemplo n.º 27
0
 /// <inheritdoc/>
 public async Task StartTestRunWithCustomHostAsync(IEnumerable <TestCase> testCases, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler, ITestHostLauncher customHostLauncher)
 {
     await this.SendMessageAndListenAndReportTestResultsAsync(
         MessageType.GetTestRunnerProcessStartInfoForRunSelected,
         new TestRunRequestPayload()
     {
         TestCases           = testCases.ToList(),
         RunSettings         = runSettings,
         DebuggingEnabled    = customHostLauncher.IsDebug,
         TestPlatformOptions = options
     },
         runEventsHandler,
         customHostLauncher);
 }
Exemplo n.º 28
0
        private async Task SendMessageAndListenAndReportTestCasesAsync(IEnumerable <string> sources, string runSettings, TestPlatformOptions options, ITestDiscoveryEventsHandler2 eventHandler)
        {
            try
            {
                this.communicationManager.SendMessage(
                    MessageType.StartDiscovery,
                    new DiscoveryRequestPayload()
                {
                    Sources = sources, RunSettings = runSettings, TestPlatformOptions = options
                },
                    this.protocolVersion);
                var isDiscoveryComplete = false;

                // Cycle through the messages that the vstest.console sends.
                // Currently each of the operations are not separate tasks since they should not each take much time.
                // This is just a notification.
                while (!isDiscoveryComplete)
                {
                    var message = await this.TryReceiveMessageAsync();

                    if (string.Equals(MessageType.TestCasesFound, message.MessageType))
                    {
                        var testCases = this.dataSerializer.DeserializePayload <IEnumerable <TestCase> >(message);

                        eventHandler.HandleDiscoveredTests(testCases);
                    }
                    else if (string.Equals(MessageType.DiscoveryComplete, message.MessageType))
                    {
                        if (EqtTrace.IsInfoEnabled)
                        {
                            EqtTrace.Info("VsTestConsoleRequestSender.SendMessageAndListenAndReportTestCasesAsync: Discovery complete.");
                        }

                        var discoveryCompletePayload =
                            this.dataSerializer.DeserializePayload <DiscoveryCompletePayload>(message);

                        var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(discoveryCompletePayload.TotalTests, discoveryCompletePayload.IsAborted);

                        // Adding Metrics from VsTestConsole
                        discoveryCompleteEventArgs.Metrics = discoveryCompletePayload.Metrics;

                        eventHandler.HandleDiscoveryComplete(
                            discoveryCompleteEventArgs,
                            discoveryCompletePayload.LastDiscoveredTests);
                        isDiscoveryComplete = true;
                    }
                    else if (string.Equals(MessageType.TestMessage, message.MessageType))
                    {
                        var testMessagePayload = this.dataSerializer.DeserializePayload <TestMessagePayload>(message);
                        eventHandler.HandleLogMessage(testMessagePayload.MessageLevel, testMessagePayload.Message);
                    }
                }
            }
            catch (Exception exception)
            {
                EqtTrace.Error("Aborting Test Discovery Operation: {0}", exception);

                eventHandler.HandleLogMessage(TestMessageLevel.Error, TranslationLayerResources.AbortedTestsDiscovery);

                var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(-1, true);
                eventHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, null);

                // Earlier we were closing the connection with vstest.console in case of exceptions
                // Removing that code because vstest.console might be in a healthy state and letting the client
                // know of the error, so that the TL can wait for the next instruction from the client itself.
                // Also, connection termination might not kill the process which could result in files being locked by testhost.
            }

            this.testPlatformEventSource.TranslationLayerDiscoveryStop();
        }
Exemplo n.º 29
0
        /// <inheritdoc/>
        public void StartTestRunWithCustomHost(IEnumerable <TestCase> testCases, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler, ITestHostLauncher customHostLauncher)
        {
            if (EqtTrace.IsInfoEnabled)
            {
                EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHost: Starting test run.");
            }

            this.SendMessageAndListenAndReportTestResults(
                MessageType.GetTestRunnerProcessStartInfoForRunSelected,
                new TestRunRequestPayload
            {
                TestCases           = testCases.ToList(),
                RunSettings         = runSettings,
                DebuggingEnabled    = customHostLauncher.IsDebug,
                TestPlatformOptions = options
            },
                runEventsHandler,
                customHostLauncher);
        }
 /// <inheritdoc/>
 public void DiscoverTests(IEnumerable <string> sources, string discoverySettings, TestPlatformOptions options, ITestDiscoveryEventsHandler2 discoveryEventsHandler)
 {
     this.testPlatformEventSource.TranslationLayerDiscoveryStart();
     this.EnsureInitialized();
     this.requestSender.DiscoverTests(sources, discoverySettings, options, discoveryEventsHandler);
 }