/// <inheritdoc/> public void StartTestSession( IRequestData requestData, StartTestSessionCriteria testSessionCriteria, ITestSessionEventsHandler eventsHandler) { if (testSessionCriteria == null) { throw new ArgumentNullException(nameof(testSessionCriteria)); } this.AddExtensionAssemblies(testSessionCriteria.RunSettings); var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(testSessionCriteria.RunSettings); // Update extension assemblies from source when design mode is false. // // TODO (copoiena): Is it possible for this code to run if we're not in design mode ? // An use case for this would be when running tests with "dotnet test". Usually there's // a build involved then. if (!runConfiguration.DesignMode) { return; } // Initialize loggers. var loggerManager = this.TestEngine.GetLoggerManager(requestData); loggerManager.Initialize(testSessionCriteria.RunSettings); var testHostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(testSessionCriteria.RunSettings); ThrowExceptionIfTestHostManagerIsNull(testHostManager, testSessionCriteria.RunSettings); testHostManager.Initialize(TestSessionMessageLogger.Instance, testSessionCriteria.RunSettings); if (testSessionCriteria.TestHostLauncher != null) { testHostManager.SetCustomLauncher(testSessionCriteria.TestHostLauncher); } var testSessionManager = this.TestEngine.GetTestSessionManager(requestData, testHostManager, testSessionCriteria); if (testSessionManager == null) { // The test session manager is null because the combination of runsettings and // sources tells us we should run in-process (i.e. in vstest.console). Because // of this no session will be created because there's no testhost to be launched. // Expecting a subsequent call to execute tests with the same set of parameters. eventsHandler.HandleStartTestSessionComplete(null); return; } testSessionManager.Initialize(false); testSessionManager.StartSession(testSessionCriteria, eventsHandler); }
/// <inheritdoc/> public bool StopTestSession( TestSessionInfo testSessionInfo, ITestSessionEventsHandler eventsHandler) { this.testPlatformEventSource.TranslationLayerStopTestSessionStart(); this.EnsureInitialized(); return(this.requestSender.StopTestSession( testSessionInfo, eventsHandler)); }
/// <inheritdoc/> public async Task <ITestSession> StartTestSessionAsync( IList <string> sources, string runSettings, ITestSessionEventsHandler eventsHandler) { return(await this.StartTestSessionAsync( sources, runSettings, options : null, eventsHandler).ConfigureAwait(false)); }
/// <inheritdoc/> public ITestSession StartTestSession( IList <string> sources, string runSettings, ITestSessionEventsHandler eventsHandler) { return(this.StartTestSession( sources, runSettings, options: null, eventsHandler)); }
/// <inheritdoc/> public async Task <bool> StopTestSessionAsync( TestSessionInfo testSessionInfo, ITestSessionEventsHandler eventsHandler) { this.testPlatformEventSource.TranslationLayerStopTestSessionStart(); await this.EnsureInitializedAsync().ConfigureAwait(false); return(await this.requestSender.StopTestSessionAsync( testSessionInfo, eventsHandler).ConfigureAwait(false)); }
/// <inheritdoc/> public ITestSession StartTestSession( IList <string> sources, string runSettings, TestPlatformOptions options, ITestSessionEventsHandler eventsHandler) { return(this.StartTestSession( sources, runSettings, options, eventsHandler, testHostLauncher: null)); }
/// <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)); }
/// <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)); }
/// <inheritdoc/> public void StartSession( StartTestSessionCriteria criteria, ITestSessionEventsHandler eventsHandler) { var testSessionInfo = new TestSessionInfo(); Task[] taskList = new Task[this.parallelLevel]; // Create all the proxies in parallel, one task per proxy. for (int i = 0; i < this.parallelLevel; ++i) { taskList[i] = Task.Factory.StartNew(() => { // Create the proxy. var operationManagerProxy = this.CreateProxy(); // Initialize the proxy. operationManagerProxy.Initialize(this.skipDefaultAdapters); // Start the test host associated to the proxy. operationManagerProxy.SetupChannel( criteria.Sources, criteria.RunSettings, eventsHandler); }); } // Wait for proxy creation to be over. Task.WaitAll(taskList); // Make the session available. TestSessionPool.Instance.AddSession(testSessionInfo, this); // Let the caller know the session has been created. eventsHandler.HandleStartTestSessionComplete(testSessionInfo); }
/// <inheritdoc/> public async Task <bool> StopTestSessionAsync(ITestSessionEventsHandler eventsHandler) { return(await this.consoleWrapper.StopTestSessionAsync( this.testSessionInfo, eventsHandler)); }
/// <inheritdoc/> public bool StopTestSession(ITestSessionEventsHandler eventsHandler) { return(this.consoleWrapper.StopTestSession( this.testSessionInfo, eventsHandler)); }
/// <inheritdoc/> public void StartTestSession( StartTestSessionPayload payload, ITestHostLauncher testHostLauncher, ITestSessionEventsHandler eventsHandler, ProtocolConfig protocolConfig) { EqtTrace.Info("TestRequestManager.StartTestSession: Starting test session."); if (payload.TestPlatformOptions != null) { this.telemetryOptedIn = payload.TestPlatformOptions.CollectMetrics; } var requestData = this.GetRequestData(protocolConfig); if (this.UpdateRunSettingsIfRequired( payload.RunSettings, payload.Sources, null, out string updatedRunsettings)) { payload.RunSettings = updatedRunsettings; } if (InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings(payload.RunSettings)) { throw new SettingsException( string.Format( Resources.RunsettingsWithDCErrorMessage, payload.RunSettings)); } // TODO (copoiena): Collect metrics ? lock (this.syncObject) { try { EqtTrace.Info("TestRequestManager.StartTestRunner: Synchronization context taken."); this.TestPlatformEventSourceInstance.StartTestSessionStart(); var criteria = new StartTestSessionCriteria() { Sources = payload.Sources, RunSettings = payload.RunSettings, TestHostLauncher = testHostLauncher }; this.testPlatform.StartTestSession(requestData, criteria, eventsHandler); } finally { EqtTrace.Info("TestRequestManager.StartTestSession: Starting test session completed."); this.TestPlatformEventSourceInstance.StartTestSessionStop(); // Post the attachments processing complete event. this.metricsPublisher.Result.PublishMetrics( TelemetryDataConstants.StartTestSessionCompleteEvent, requestData.MetricsCollection.Metrics); } } }