From e98195aae64514ce55662f81e40ba47e0547f1cf Mon Sep 17 00:00:00 2001 From: faahmad Date: Thu, 27 Jul 2017 14:56:36 +0530 Subject: [PATCH 1/8] No isolation discovery for net46 with design mode off --- .../NoIsolationProxyDiscoveryManager.cs | 71 +++++++++ .../Discovery/DiscoveryManager.cs | 7 +- .../TestEngine.cs | 19 ++- .../RunSettings/RunConfiguration.cs | 51 ++++++- .../CommandLine/CommandLineOptions.cs | 5 + .../NoIsolationArgumentProcessor.cs | 140 ++++++++++++++++++ .../Utilities/ArgumentProcessorFactory.cs | 1 + .../Utilities/HelpContentPriority.cs | 5 + 8 files changed, 295 insertions(+), 4 deletions(-) create mode 100644 src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs create mode 100644 src/vstest.console/Processors/NoIsolationArgumentProcessor.cs diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs new file mode 100644 index 0000000000..a39cca198c --- /dev/null +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +{ + using System.Linq; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + + class NoIsolationProxyDiscoveryManager : IProxyDiscoveryManager + { + private ITestHostManagerFactory testHostManagerFactory; + + /// + /// Initializes a new instance of the class. + /// + public NoIsolationProxyDiscoveryManager() : this(new TestHostManagerFactory()) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Manager factory + /// + protected NoIsolationProxyDiscoveryManager(ITestHostManagerFactory testHostManagerFactory) + { + this.testHostManagerFactory = testHostManagerFactory; + } + + /// + /// Initializes test discovery. Create the test host, setup channel and initialize extensions. + /// This function is of no use in this context as we are not creating any testhost + /// + public void Initialize() + { + } + + /// + /// Discovers tests + /// + /// Settings, parameters for the discovery request + /// EventHandler for handling discovery events from Engine + public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler eventHandler) + { + var discoveryManager = this.testHostManagerFactory.GetDiscoveryManager(); + + // Initialize extension before discovery + discoveryManager.Initialize(Enumerable.Empty()); + discoveryManager.DiscoverTests(discoveryCriteria, eventHandler); + } + + /// + /// Closes the current test operation. + /// This function is of no use in this context as we are not creating any testhost + /// + public void Close() + { + } + + /// + /// Aborts the test operation. + /// + public void Abort() + { + this.testHostManagerFactory.GetDiscoveryManager().Abort(); + } + } +} diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs index f569071934..e9017a3b5f 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs @@ -61,8 +61,11 @@ public void Initialize(IEnumerable pathToAdditionalExtensions) { this.testPlatformEventSource.AdapterSearchStart(); - // Start using these additional extensions - TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions; + if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Count() > 0) + { + // Start using these additional extensions + TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions; + } // Load and Initialize extensions. TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs index 04041bbbf6..783d9763f8 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs @@ -59,6 +59,11 @@ public IProxyDiscoveryManager GetDiscoveryManager(ITestRuntimeProvider testHostM { var parallelLevel = this.VerifyParallelSettingAndCalculateParallelLevel(discoveryCriteria.Sources.Count(), discoveryCriteria.RunSettings); + if(ShouldRunInNoIsolation(discoveryCriteria.RunSettings)) + { + return new NoIsolationProxyDiscoveryManager(); + } + Func proxyDiscoveryManagerCreator = delegate { var hostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(discoveryCriteria.RunSettings); @@ -66,7 +71,7 @@ public IProxyDiscoveryManager GetDiscoveryManager(ITestRuntimeProvider testHostM return new ProxyDiscoveryManager(new TestRequestSender(protocolConfig), hostManager); }; - + return !testHostManager.Shared ? new ParallelProxyDiscoveryManager(proxyDiscoveryManagerCreator, parallelLevel, sharedHosts: testHostManager.Shared) : proxyDiscoveryManagerCreator(); } @@ -193,5 +198,17 @@ private int VerifyParallelSettingAndCalculateParallelLevel(int sourceCount, stri return parallelLevelToUse; } + + private bool ShouldRunInNoIsolation(string runsettings) + { + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings); + if(runConfiguration.NoIsolation && !runConfiguration.DesignMode && !(runConfiguration.TargetFrameworkVersion.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 + || runConfiguration.TargetFrameworkVersion.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0)) + { + return true; + } + + return false; + } } } diff --git a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs index 42c221bf83..f08d2086b4 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs @@ -58,6 +58,11 @@ public class RunConfiguration : TestRunSettings /// private bool disableAppDomain; + /// + /// Specify to not run tests in isolation. + /// + private bool noIsolation; + /// /// Indication to adapters to disable parallelization. /// @@ -94,6 +99,7 @@ public RunConfiguration() : base(Constants.RunConfigurationSettingsName) this.batchSize = Constants.DefaultBatchSize; this.testSessionTimeout = 0; this.disableAppDomain = false; + this.noIsolation = false; this.disableParallelization = false; this.designMode = false; this.shouldCollectSourceInformation = false; @@ -228,6 +234,23 @@ public bool DisableAppDomain } } + /// + /// Gets or sets a value indicating whether to run tests in isolation or not. + /// + public bool NoIsolation + { + get + { + return this.noIsolation; + } + + set + { + this.noIsolation = value; + this.NoIsolationSet = true; + } + } + /// /// Gets a value indicating whether parallelism needs to be disabled by the adapters. /// @@ -355,7 +378,7 @@ public bool DesignModeSet } /// - /// Gets a value indicating whether app domain needs to be disabled by the adapters. + /// Gets a value indicating whether disable appdomain is set. /// public bool DisableAppDomainSet { @@ -363,6 +386,15 @@ public bool DisableAppDomainSet private set; } + /// + /// Gets a value indicating whether NoIsolation is set. + /// + public bool NoIsolationSet + { + get; + private set; + } + /// /// Gets a value indicating whether parallelism needs to be disabled by the adapters. /// @@ -452,6 +484,10 @@ public override XmlElement ToXml() disableAppDomain.InnerXml = this.DisableAppDomain.ToString(); root.AppendChild(disableAppDomain); + XmlElement noIsolation = doc.CreateElement("NoIsolation"); + noIsolation.InnerXml = this.NoIsolation.ToString(); + root.AppendChild(noIsolation); + XmlElement disableParallelization = doc.CreateElement("DisableParallelization"); disableParallelization.InnerXml = this.DisableParallelization.ToString(); root.AppendChild(disableParallelization); @@ -605,6 +641,19 @@ public static RunConfiguration FromXml(XmlReader reader) runConfiguration.DisableAppDomain = disableAppDomainCheck; break; + case "NoIsolation": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + + string noIsolationValueString = reader.ReadElementContentAsString(); + bool noIsolationCheck; + if (!bool.TryParse(noIsolationValueString, out noIsolationCheck)) + { + throw new SettingsException(String.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, noIsolationValueString, elementName)); + } + runConfiguration.NoIsolation = noIsolationCheck; + break; + case "DisableParallelization": XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); diff --git a/src/vstest.console/CommandLine/CommandLineOptions.cs b/src/vstest.console/CommandLine/CommandLineOptions.cs index c02a76f1bf..c6520409f2 100644 --- a/src/vstest.console/CommandLine/CommandLineOptions.cs +++ b/src/vstest.console/CommandLine/CommandLineOptions.cs @@ -97,6 +97,11 @@ protected CommandLineOptions() /// public bool Parallel { get; set; } + /// + /// Specifies whether NoIsolation is on or off. + /// + public bool NoIsolation { get; set; } + /// /// Readonly collection of all available test sources /// diff --git a/src/vstest.console/Processors/NoIsolationArgumentProcessor.cs b/src/vstest.console/Processors/NoIsolationArgumentProcessor.cs new file mode 100644 index 0000000000..cfb2423045 --- /dev/null +++ b/src/vstest.console/Processors/NoIsolationArgumentProcessor.cs @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Diagnostics.Contracts; +using System.Globalization; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; + +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +{ + internal class NoIsolationArgumentProcessor : IArgumentProcessor + { + #region Constants + + public const string CommandName = "/NoIsolation"; + + #endregion + + private Lazy metadata; + + private Lazy executor; + + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get + { + if (this.metadata == null) + { + this.metadata = new Lazy(() => new NoIsolationArgumentProcessorCapabilities()); + } + + return this.metadata; + } + } + + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get + { + if (this.executor == null) + { + this.executor = new Lazy(() => new NoIsolationArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); + } + + return this.executor; + } + + set + { + this.executor = value; + } + } + } + + internal class NoIsolationArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities + { + public override string CommandName => NoIsolationArgumentProcessor.CommandName; + + public override bool AllowMultiple => false; + + public override bool IsAction => false; + + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; + + public override string HelpContentResourceName => "Help message for NoIsolation"; + + public override HelpContentPriority HelpPriority => HelpContentPriority.NoIsolationArgumentProcessorHelpPriority; + } + + internal class NoIsolationArgumentExecutor : IArgumentExecutor + { + #region Fields + + /// + /// Used for getting sources. + /// + private CommandLineOptions commandLineOptions; + + private IRunSettingsProvider runSettingsManager; + + public const string RunSettingsPath = "RunConfiguration.NoIsolation"; + + #endregion + + #region Constructor + + /// + /// Default constructor. + /// + /// The options. + /// The runsettings manager. + public NoIsolationArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) + { + Contract.Requires(options != null); + Contract.Requires(runSettingsManager != null); + this.commandLineOptions = options; + this.runSettingsManager = runSettingsManager; + } + + #endregion + + #region IArgumentExecutor + + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + // NoIsolation does not require any argument, throws exception if argument specified + if (!string.IsNullOrWhiteSpace(argument)) + { + throw new CommandLineException( + string.Format(CultureInfo.CurrentCulture, "Place holder for error mesaage", argument)); + } + + commandLineOptions.NoIsolation = true; + this.runSettingsManager.UpdateRunSettingsNode(NoIsolationArgumentExecutor.RunSettingsPath, "true"); + } + + /// + /// The output path is already set, return success. + /// + /// The Success + public ArgumentProcessorResult Execute() + { + return ArgumentProcessorResult.Success; + } + + #endregion + } +} diff --git a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs index c7eb830b1e..9f6bb6d156 100644 --- a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs +++ b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs @@ -228,6 +228,7 @@ public IEnumerable GetArgumentProcessorsToAlwaysExecute() new FrameworkArgumentProcessor(), new EnableLoggerArgumentProcessor(), new ParallelArgumentProcessor(), + new NoIsolationArgumentProcessor(), new EnableDiagArgumentProcessor(), new CLIRunSettingsArgumentProcessor(), new ResultsDirectoryArgumentProcessor(), diff --git a/src/vstest.console/Processors/Utilities/HelpContentPriority.cs b/src/vstest.console/Processors/Utilities/HelpContentPriority.cs index ee9d1435c3..391a0a7f9f 100644 --- a/src/vstest.console/Processors/Utilities/HelpContentPriority.cs +++ b/src/vstest.console/Processors/Utilities/HelpContentPriority.cs @@ -87,6 +87,11 @@ internal enum HelpContentPriority /// ParallelArgumentProcessorHelpPriority, + /// + /// NoIsolationArgumentProcessor Help + /// + NoIsolationArgumentProcessorHelpPriority, + /// /// TestAdapterPathArgumentProcessor Help /// From ddb91be1b14b2695876a61a1879c0664e7addf66 Mon Sep 17 00:00:00 2001 From: faahmad Date: Thu, 27 Jul 2017 22:57:03 +0530 Subject: [PATCH 2/8] NoIsolation test run for net46 --- .../NoIsolationProxyexecutionManager.cs | 96 +++++++++++++++++++ .../Execution/ExecutionManager.cs | 10 +- .../TestEngine.cs | 5 + .../Processors/RunTestsArgumentProcessor.cs | 2 +- 4 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs new file mode 100644 index 0000000000..8604603268 --- /dev/null +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +{ + using System.Linq; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + + class NoIsolationProxyexecutionManager : IProxyExecutionManager + { + private ITestHostManagerFactory testHostManagerFactory; + public bool IsInitialized { get; private set; } = false; + + /// + /// Initializes a new instance of the class. + /// + public NoIsolationProxyexecutionManager() : this(new TestHostManagerFactory()) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Manager factory + /// + protected NoIsolationProxyexecutionManager(ITestHostManagerFactory testHostManagerFactory) + { + this.testHostManagerFactory = testHostManagerFactory; + } + + public void Initialize() + { + this.IsInitialized = true; + } + + public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) + { + // Initialize extension before execution + var executionManager = this.testHostManagerFactory.GetExecutionManager(); + + executionManager.Initialize(Enumerable.Empty()); + + var executionContext = new TestExecutionContext( + testRunCriteria.FrequencyOfRunStatsChangeEvent, + testRunCriteria.RunStatsChangeEventTimeout, + inIsolation: false, + keepAlive: testRunCriteria.KeepAlive, + isDataCollectionEnabled: false, + areTestCaseLevelEventsRequired: false, + hasTestRun: true, + isDebug: (testRunCriteria.TestHostLauncher != null && testRunCriteria.TestHostLauncher.IsDebug), + testCaseFilter: testRunCriteria.TestCaseFilter); + + if (testRunCriteria.HasSpecificSources) + { + // [TODO]: we need to revisit to second-last argument if we will enable datacollector. + executionManager.StartTestRun(testRunCriteria.AdapterSourceMap, testRunCriteria.TestRunSettings, executionContext, null, eventHandler); + } + else + { + // [TODO]: we need to revisit to second-last argument if we will enable datacollector. + executionManager.StartTestRun(testRunCriteria.Tests, testRunCriteria.TestRunSettings, executionContext, null, eventHandler); + } + + return 0; + } + + /// + /// Aborts the test operation. + /// + public void Abort() + { + this.testHostManagerFactory.GetExecutionManager().Abort(); + } + + /// + /// Cancels the test run. + /// + public void Cancel() + { + this.testHostManagerFactory.GetExecutionManager().Cancel(); + } + + /// + /// Closes the current test operation. + /// This function is of no use in this context as we are not creating any testhost + /// + public void Close() + { + } + } +} diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs index 209c29c99d..8b127a89d8 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs @@ -5,7 +5,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution { using System; using System.Collections.Generic; - + using System.Linq; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; @@ -53,8 +53,12 @@ public void Initialize(IEnumerable pathToAdditionalExtensions) { this.testPlatformEventSource.AdapterSearchStart(); - // Start using these additional extensions - TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions; + if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Count() > 0) + { + // Start using these additional extensions + TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions; + } + this.LoadExtensions(); this.testPlatformEventSource.AdapterSearchStop(); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs index 783d9763f8..a1a6dfbc16 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs @@ -91,6 +91,11 @@ public IProxyExecutionManager GetExecutionManager(ITestRuntimeProvider testHostM var isDataCollectorEnabled = XmlRunSettingsUtilities.IsDataCollectionEnabled(testRunCriteria.TestRunSettings); + if (parallelLevel <= 1 && !isDataCollectorEnabled && ShouldRunInNoIsolation(testRunCriteria.TestRunSettings)) + { + return new NoIsolationProxyexecutionManager(); + } + // SetupChannel ProxyExecutionManager with data collection if data collectors are specififed in run settings. Func proxyExecutionManagerCreator = delegate { diff --git a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs index 237eea18a1..c1db8a84b2 100644 --- a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs @@ -199,7 +199,7 @@ private bool RunTests(IEnumerable sources) GenerateFakesUtilities.GenerateFakesSettings(this.commandLineOptions, this.commandLineOptions.Sources.ToList(), ref runSettings); var runRequestPayload = new TestRunRequestPayload() { Sources = this.commandLineOptions.Sources.ToList(), RunSettings = runSettings, KeepAlive = keepAlive }; - var result = this.testRequestManager.RunTests(runRequestPayload, null, this.testRunEventsRegistrar, Constants.DefaultProtocolConfig); + var result = this.testRequestManager.RunTests(runRequestPayload, null, null, Constants.DefaultProtocolConfig); if (EqtTrace.IsInfoEnabled) { From a881a1ab28bdefa60cc1737f642b8303da5f6608 Mon Sep 17 00:00:00 2001 From: Faizan Ahmad Date: Tue, 15 Aug 2017 13:26:29 +0530 Subject: [PATCH 3/8] Make api asynchronous --- .../Client/NoIsolationProxyDiscoveryManager.cs | 11 ++++++++--- .../Client/NoIsolationProxyexecutionManager.cs | 9 +++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs index a39cca198c..9b338d9c1e 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs @@ -7,6 +7,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + using System.Threading.Tasks; class NoIsolationProxyDiscoveryManager : IProxyDiscoveryManager { @@ -48,8 +49,12 @@ public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEve var discoveryManager = this.testHostManagerFactory.GetDiscoveryManager(); // Initialize extension before discovery - discoveryManager.Initialize(Enumerable.Empty()); - discoveryManager.DiscoverTests(discoveryCriteria, eventHandler); + Task.Run(() => + { + discoveryManager.Initialize(Enumerable.Empty()); + discoveryManager.DiscoverTests(discoveryCriteria, eventHandler); + } + ); } /// @@ -65,7 +70,7 @@ public void Close() /// public void Abort() { - this.testHostManagerFactory.GetDiscoveryManager().Abort(); + Task.Run(() => this.testHostManagerFactory.GetDiscoveryManager().Abort()); } } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs index 8604603268..967ee184f5 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs @@ -8,6 +8,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + using System.Threading.Tasks; class NoIsolationProxyexecutionManager : IProxyExecutionManager { @@ -58,12 +59,12 @@ public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler e if (testRunCriteria.HasSpecificSources) { // [TODO]: we need to revisit to second-last argument if we will enable datacollector. - executionManager.StartTestRun(testRunCriteria.AdapterSourceMap, testRunCriteria.TestRunSettings, executionContext, null, eventHandler); + Task.Run(() => executionManager.StartTestRun(testRunCriteria.AdapterSourceMap, testRunCriteria.TestRunSettings, executionContext, null, eventHandler)); } else { // [TODO]: we need to revisit to second-last argument if we will enable datacollector. - executionManager.StartTestRun(testRunCriteria.Tests, testRunCriteria.TestRunSettings, executionContext, null, eventHandler); + Task.Run(() => executionManager.StartTestRun(testRunCriteria.Tests, testRunCriteria.TestRunSettings, executionContext, null, eventHandler)); } return 0; @@ -74,7 +75,7 @@ public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler e /// public void Abort() { - this.testHostManagerFactory.GetExecutionManager().Abort(); + Task.Run(() => this.testHostManagerFactory.GetExecutionManager().Abort()); } /// @@ -82,7 +83,7 @@ public void Abort() /// public void Cancel() { - this.testHostManagerFactory.GetExecutionManager().Cancel(); + Task.Run(() => this.testHostManagerFactory.GetExecutionManager().Cancel()); } /// From ede0e0437a416b9b19006acba9cc4ae8580faf23 Mon Sep 17 00:00:00 2001 From: faahmad Date: Fri, 18 Aug 2017 22:51:21 +0530 Subject: [PATCH 4/8] 1) Renamed argument processor to InProcess 2) Wrote unit tests. --- .../Client/InProcessProxyDiscoveryManager.cs | 101 +++++++++ .../Client/InProcessProxyexecutionManager.cs | 127 +++++++++++ .../NoIsolationProxyDiscoveryManager.cs | 76 ------- .../NoIsolationProxyexecutionManager.cs | 97 --------- .../TestEngine.cs | 35 +++- .../RunSettings/RunConfiguration.cs | 34 +-- .../CommandLine/CommandLineOptions.cs | 4 +- ...essor.cs => InProcessArgumentProcessor.cs} | 48 +++-- .../Processors/RunTestsArgumentProcessor.cs | 2 +- .../Utilities/ArgumentProcessorFactory.cs | 2 +- .../Utilities/HelpContentPriority.cs | 4 +- .../Resources/Resources.Designer.cs | 24 +++ src/vstest.console/Resources/Resources.resx | 8 + .../Resources/xlf/Resources.cs.xlf | 14 ++ .../Resources/xlf/Resources.de.xlf | 14 ++ .../Resources/xlf/Resources.es.xlf | 14 ++ .../Resources/xlf/Resources.fr.xlf | 14 ++ .../Resources/xlf/Resources.it.xlf | 14 ++ .../Resources/xlf/Resources.ja.xlf | 14 ++ .../Resources/xlf/Resources.ko.xlf | 14 ++ .../Resources/xlf/Resources.pl.xlf | 14 ++ .../Resources/xlf/Resources.pt-BR.xlf | 14 ++ .../Resources/xlf/Resources.ru.xlf | 14 ++ .../Resources/xlf/Resources.tr.xlf | 14 ++ .../Resources/xlf/Resources.xlf | 14 ++ .../Resources/xlf/Resources.zh-Hans.xlf | 14 ++ .../Resources/xlf/Resources.zh-Hant.xlf | 14 ++ .../InProcessProxyDiscoveryManagerTests.cs | 138 ++++++++++++ .../InProcessProxyexecutionManagerTests.cs | 158 ++++++++++++++ .../TestEngineTests.cs | 197 +++++++++++++++++- .../TestableTestEngine.cs | 6 +- .../RunSettings/RunConfigurationTests.cs | 3 + .../InProcessArgumentProcessorTests.cs | 94 +++++++++ 33 files changed, 1122 insertions(+), 232 deletions(-) create mode 100644 src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs create mode 100644 src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs delete mode 100644 src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs delete mode 100644 src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs rename src/vstest.console/Processors/{NoIsolationArgumentProcessor.cs => InProcessArgumentProcessor.cs} (64%) create mode 100644 test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs create mode 100644 test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs create mode 100644 test/vstest.console.UnitTests/Processors/InProcessArgumentProcessorTests.cs diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs new file mode 100644 index 0000000000..67725b50cd --- /dev/null +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + + class InProcessProxyDiscoveryManager : IProxyDiscoveryManager + { + private ITestHostManagerFactory testHostManagerFactory; + public bool IsInitialized { get; private set; } = false; + + /// + /// Initializes a new instance of the class. + /// + public InProcessProxyDiscoveryManager() : this(new TestHostManagerFactory()) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Manager factory + internal InProcessProxyDiscoveryManager(ITestHostManagerFactory testHostManagerFactory) + { + this.testHostManagerFactory = testHostManagerFactory; + } + + /// + /// Initializes test discovery. + /// + public void Initialize() + { + if(!this.IsInitialized) + { + var discoveryManager = this.testHostManagerFactory.GetDiscoveryManager(); + + // We don't need to pass list of extension as we are running inside vstest.console and + // it will use TestPluginCache of vstest.console + discoveryManager.Initialize(Enumerable.Empty()); + this.IsInitialized = true; + } + } + + /// + /// Discovers tests + /// + /// Settings, parameters for the discovery request + /// EventHandler for handling discovery events from Engine + public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler eventHandler) + { + var discoveryManager = this.testHostManagerFactory.GetDiscoveryManager(); + + Task.Run(() => + { + try + { + // Initialize extension before discovery if it’s not initialized + if (!this.IsInitialized) + { + discoveryManager.Initialize(Enumerable.Empty()); + } + discoveryManager.DiscoverTests(discoveryCriteria, eventHandler); + } + catch (Exception exception) + { + EqtTrace.Error("InProcessProxyDiscoveryManager.DiscoverTests: Failed to discover tests: {0}", exception); + + // Send a discovery complete to caller. + eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.Message); + eventHandler.HandleDiscoveryComplete(-1, new List(), true); + } + } + ); + } + + /// + /// Closes the current test operation. + /// This function is of no use in this context as we are not creating any testhost + /// + public void Close() + { + } + + /// + /// Aborts the test operation. + /// + public void Abort() + { + Task.Run(() => this.testHostManagerFactory.GetDiscoveryManager().Abort()); + } + } +} diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs new file mode 100644 index 0000000000..ac3a76e50d --- /dev/null +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +{ + using System; + using System.Collections.ObjectModel; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + + class InProcessProxyExecutionManager : IProxyExecutionManager + { + private ITestHostManagerFactory testHostManagerFactory; + public bool IsInitialized { get; private set; } = false; + + /// + /// Initializes a new instance of the class. + /// + public InProcessProxyExecutionManager() : this(new TestHostManagerFactory()) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Manager factory + /// + internal InProcessProxyExecutionManager(ITestHostManagerFactory testHostManagerFactory) + { + this.testHostManagerFactory = testHostManagerFactory; + } + + public void Initialize() + { + if (!this.IsInitialized) + { + var executionManager = this.testHostManagerFactory.GetExecutionManager(); + + // We don't need to pass list of extension as we are running inside vstest.console and + // it will use TestPluginCache of vstest.console + executionManager.Initialize(Enumerable.Empty()); + this.IsInitialized = true; + } + } + + public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) + { + try + { + var executionManager = this.testHostManagerFactory.GetExecutionManager(); + + // Initialize extension before execution if not already initialized + if (!this.IsInitialized) + { + executionManager.Initialize(Enumerable.Empty()); + } + + var executionContext = new TestExecutionContext( + testRunCriteria.FrequencyOfRunStatsChangeEvent, + testRunCriteria.RunStatsChangeEventTimeout, + inIsolation: false, + keepAlive: testRunCriteria.KeepAlive, + isDataCollectionEnabled: false, + areTestCaseLevelEventsRequired: false, + hasTestRun: true, + isDebug: (testRunCriteria.TestHostLauncher != null && testRunCriteria.TestHostLauncher.IsDebug), + testCaseFilter: testRunCriteria.TestCaseFilter); + + + if (testRunCriteria.HasSpecificSources) + { + // [TODO]: we need to revisit to second-last argument if we will enable datacollector. + Task.Run(() => executionManager.StartTestRun(testRunCriteria.AdapterSourceMap, testRunCriteria.TestRunSettings, executionContext, null, eventHandler)); + } + else + { + // [TODO]: we need to revisit to second-last argument if we will enable datacollector. + Task.Run(() => executionManager.StartTestRun(testRunCriteria.Tests, testRunCriteria.TestRunSettings, executionContext, null, eventHandler)); + } + } + catch (Exception exception) + { + EqtTrace.Error("InProcessProxyexecutionManager.StartTestRun: Failed to start test run: {0}", exception); + + // Send a discovery complete to caller. + eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.Message); + + // Send a run complete to caller. + var completeArgs = new TestRunCompleteEventArgs(null, false, true, exception, new Collection(), TimeSpan.Zero); + eventHandler.HandleTestRunComplete(completeArgs, null, null, null); + } + + return 0; + } + + /// + /// Aborts the test operation. + /// + public void Abort() + { + Task.Run(() => this.testHostManagerFactory.GetExecutionManager().Abort()); + } + + /// + /// Cancels the test run. + /// + public void Cancel() + { + Task.Run(() => this.testHostManagerFactory.GetExecutionManager().Cancel()); + } + + /// + /// Closes the current test operation. + /// This function is of no use in this context as we are not creating any testhost + /// + public void Close() + { + } + } +} diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs deleted file mode 100644 index 9b338d9c1e..0000000000 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyDiscoveryManager.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client -{ - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using System.Threading.Tasks; - - class NoIsolationProxyDiscoveryManager : IProxyDiscoveryManager - { - private ITestHostManagerFactory testHostManagerFactory; - - /// - /// Initializes a new instance of the class. - /// - public NoIsolationProxyDiscoveryManager() : this(new TestHostManagerFactory()) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Manager factory - /// - protected NoIsolationProxyDiscoveryManager(ITestHostManagerFactory testHostManagerFactory) - { - this.testHostManagerFactory = testHostManagerFactory; - } - - /// - /// Initializes test discovery. Create the test host, setup channel and initialize extensions. - /// This function is of no use in this context as we are not creating any testhost - /// - public void Initialize() - { - } - - /// - /// Discovers tests - /// - /// Settings, parameters for the discovery request - /// EventHandler for handling discovery events from Engine - public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler eventHandler) - { - var discoveryManager = this.testHostManagerFactory.GetDiscoveryManager(); - - // Initialize extension before discovery - Task.Run(() => - { - discoveryManager.Initialize(Enumerable.Empty()); - discoveryManager.DiscoverTests(discoveryCriteria, eventHandler); - } - ); - } - - /// - /// Closes the current test operation. - /// This function is of no use in this context as we are not creating any testhost - /// - public void Close() - { - } - - /// - /// Aborts the test operation. - /// - public void Abort() - { - Task.Run(() => this.testHostManagerFactory.GetDiscoveryManager().Abort()); - } - } -} diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs deleted file mode 100644 index 967ee184f5..0000000000 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/NoIsolationProxyexecutionManager.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client -{ - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using System.Threading.Tasks; - - class NoIsolationProxyexecutionManager : IProxyExecutionManager - { - private ITestHostManagerFactory testHostManagerFactory; - public bool IsInitialized { get; private set; } = false; - - /// - /// Initializes a new instance of the class. - /// - public NoIsolationProxyexecutionManager() : this(new TestHostManagerFactory()) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Manager factory - /// - protected NoIsolationProxyexecutionManager(ITestHostManagerFactory testHostManagerFactory) - { - this.testHostManagerFactory = testHostManagerFactory; - } - - public void Initialize() - { - this.IsInitialized = true; - } - - public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) - { - // Initialize extension before execution - var executionManager = this.testHostManagerFactory.GetExecutionManager(); - - executionManager.Initialize(Enumerable.Empty()); - - var executionContext = new TestExecutionContext( - testRunCriteria.FrequencyOfRunStatsChangeEvent, - testRunCriteria.RunStatsChangeEventTimeout, - inIsolation: false, - keepAlive: testRunCriteria.KeepAlive, - isDataCollectionEnabled: false, - areTestCaseLevelEventsRequired: false, - hasTestRun: true, - isDebug: (testRunCriteria.TestHostLauncher != null && testRunCriteria.TestHostLauncher.IsDebug), - testCaseFilter: testRunCriteria.TestCaseFilter); - - if (testRunCriteria.HasSpecificSources) - { - // [TODO]: we need to revisit to second-last argument if we will enable datacollector. - Task.Run(() => executionManager.StartTestRun(testRunCriteria.AdapterSourceMap, testRunCriteria.TestRunSettings, executionContext, null, eventHandler)); - } - else - { - // [TODO]: we need to revisit to second-last argument if we will enable datacollector. - Task.Run(() => executionManager.StartTestRun(testRunCriteria.Tests, testRunCriteria.TestRunSettings, executionContext, null, eventHandler)); - } - - return 0; - } - - /// - /// Aborts the test operation. - /// - public void Abort() - { - Task.Run(() => this.testHostManagerFactory.GetExecutionManager().Abort()); - } - - /// - /// Cancels the test run. - /// - public void Cancel() - { - Task.Run(() => this.testHostManagerFactory.GetExecutionManager().Cancel()); - } - - /// - /// Closes the current test operation. - /// This function is of no use in this context as we are not creating any testhost - /// - public void Close() - { - } - } -} diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs index c4ddfef5ad..c08b2df22e 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs @@ -18,6 +18,8 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; /// /// Cross Platform test engine entry point for the client. @@ -28,16 +30,18 @@ public class TestEngine : ITestEngine private readonly TestRuntimeProviderManager testHostProviderManager; private ITestExtensionManager testExtensionManager; + private IProcessHelper processHelper; #endregion - public TestEngine() : this(TestRuntimeProviderManager.Instance) + public TestEngine() : this(TestRuntimeProviderManager.Instance, new ProcessHelper()) { } - protected TestEngine(TestRuntimeProviderManager testHostProviderManager) + protected TestEngine(TestRuntimeProviderManager testHostProviderManager, IProcessHelper processHelper) { this.testHostProviderManager = testHostProviderManager; + this.processHelper = processHelper; } #region ITestEngine implementation @@ -59,9 +63,9 @@ public IProxyDiscoveryManager GetDiscoveryManager(ITestRuntimeProvider testHostM { var parallelLevel = this.VerifyParallelSettingAndCalculateParallelLevel(discoveryCriteria.Sources.Count(), discoveryCriteria.RunSettings); - if(ShouldRunInNoIsolation(discoveryCriteria.RunSettings)) + if (this.ShouldRunInNoIsolation(discoveryCriteria.RunSettings)) { - return new NoIsolationProxyDiscoveryManager(); + return new InProcessProxyDiscoveryManager(); } Func proxyDiscoveryManagerCreator = delegate @@ -91,9 +95,9 @@ public IProxyExecutionManager GetExecutionManager(ITestRuntimeProvider testHostM var isDataCollectorEnabled = XmlRunSettingsUtilities.IsDataCollectionEnabled(testRunCriteria.TestRunSettings); - if (parallelLevel <= 1 && !isDataCollectorEnabled && ShouldRunInNoIsolation(testRunCriteria.TestRunSettings)) + if (parallelLevel <= 1 && !isDataCollectorEnabled && this.ShouldRunInNoIsolation(testRunCriteria.TestRunSettings)) { - return new NoIsolationProxyexecutionManager(); + return new InProcessProxyExecutionManager(); } // SetupChannel ProxyExecutionManager with data collection if data collectors are specififed in run settings. @@ -113,7 +117,7 @@ public IProxyExecutionManager GetExecutionManager(ITestRuntimeProvider testHostM return isDataCollectorEnabled ? new ProxyExecutionManagerWithDataCollection(requestSender, hostManager, new ProxyDataCollectionManager(testRunCriteria.TestRunSettings)) : new ProxyExecutionManager(requestSender, hostManager); }; - + // parallelLevel = 1 for desktop should go via else route. if (parallelLevel > 1 || !testHostManager.Shared) { @@ -206,11 +210,24 @@ private int VerifyParallelSettingAndCalculateParallelLevel(int sourceCount, stri private bool ShouldRunInNoIsolation(string runsettings) { + var currentProcessPath = this.processHelper.GetCurrentProcessFileName(); + + // If running with the dotnet executable, then dont run in NoIsolation + if (currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase) + || currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings); - if(runConfiguration.NoIsolation && !runConfiguration.DesignMode && !(runConfiguration.TargetFrameworkVersion.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 + + if (runConfiguration.InProcess && + !runConfiguration.DisableAppDomain && + !runConfiguration.DesignMode && + !(runConfiguration.TargetFrameworkVersion.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 || runConfiguration.TargetFrameworkVersion.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0)) { - return true; + return true ; } return false; diff --git a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs index 3b41e2cbbb..0628a30a75 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs @@ -62,7 +62,7 @@ public class RunConfiguration : TestRunSettings /// /// Specify to not run tests in isolation. /// - private bool noIsolation; + private bool inProcess; /// /// Indication to adapters to disable parallelization. @@ -100,7 +100,7 @@ public RunConfiguration() : base(Constants.RunConfigurationSettingsName) this.batchSize = Constants.DefaultBatchSize; this.testSessionTimeout = 0; this.disableAppDomain = false; - this.noIsolation = false; + this.inProcess = false; this.disableParallelization = false; this.designMode = false; this.shouldCollectSourceInformation = false; @@ -239,17 +239,17 @@ public bool DisableAppDomain /// /// Gets or sets a value indicating whether to run tests in isolation or not. /// - public bool NoIsolation + public bool InProcess { get { - return this.noIsolation; + return this.inProcess; } set { - this.noIsolation = value; - this.NoIsolationSet = true; + this.inProcess = value; + this.InProcessSet = true; } } @@ -399,9 +399,9 @@ public bool DisableAppDomainSet } /// - /// Gets a value indicating whether NoIsolation is set. + /// Gets a value indicating whether InProcess is set. /// - public bool NoIsolationSet + public bool InProcessSet { get; private set; @@ -496,9 +496,9 @@ public override XmlElement ToXml() disableAppDomain.InnerXml = this.DisableAppDomain.ToString(); root.AppendChild(disableAppDomain); - XmlElement noIsolation = doc.CreateElement("NoIsolation"); - noIsolation.InnerXml = this.NoIsolation.ToString(); - root.AppendChild(noIsolation); + XmlElement inProcess = doc.CreateElement("InProcess"); + inProcess.InnerXml = this.InProcess.ToString(); + root.AppendChild(inProcess); XmlElement disableParallelization = doc.CreateElement("DisableParallelization"); disableParallelization.InnerXml = this.DisableParallelization.ToString(); @@ -657,17 +657,17 @@ public static RunConfiguration FromXml(XmlReader reader) runConfiguration.DisableAppDomain = disableAppDomainCheck; break; - case "NoIsolation": + case "InProcess": XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - string noIsolationValueString = reader.ReadElementContentAsString(); - bool noIsolationCheck; - if (!bool.TryParse(noIsolationValueString, out noIsolationCheck)) + string inProcessValueString = reader.ReadElementContentAsString(); + bool inProcessCheck; + if (!bool.TryParse(inProcessValueString, out inProcessCheck)) { throw new SettingsException(String.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, noIsolationValueString, elementName)); + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, inProcessValueString, elementName)); } - runConfiguration.NoIsolation = noIsolationCheck; + runConfiguration.InProcess = inProcessCheck; break; case "DisableParallelization": diff --git a/src/vstest.console/CommandLine/CommandLineOptions.cs b/src/vstest.console/CommandLine/CommandLineOptions.cs index c6520409f2..132948ffc5 100644 --- a/src/vstest.console/CommandLine/CommandLineOptions.cs +++ b/src/vstest.console/CommandLine/CommandLineOptions.cs @@ -98,9 +98,9 @@ protected CommandLineOptions() public bool Parallel { get; set; } /// - /// Specifies whether NoIsolation is on or off. + /// Specifies whether InProcess is on or off. /// - public bool NoIsolation { get; set; } + public bool InProcess { get; set; } /// /// Readonly collection of all available test sources diff --git a/src/vstest.console/Processors/NoIsolationArgumentProcessor.cs b/src/vstest.console/Processors/InProcessArgumentProcessor.cs similarity index 64% rename from src/vstest.console/Processors/NoIsolationArgumentProcessor.cs rename to src/vstest.console/Processors/InProcessArgumentProcessor.cs index cfb2423045..8ea735d437 100644 --- a/src/vstest.console/Processors/NoIsolationArgumentProcessor.cs +++ b/src/vstest.console/Processors/InProcessArgumentProcessor.cs @@ -1,20 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; -using System.Diagnostics.Contracts; -using System.Globalization; -using Microsoft.VisualStudio.TestPlatform.Common; -using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; -using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; - namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors { - internal class NoIsolationArgumentProcessor : IArgumentProcessor + using System; + using System.Diagnostics.Contracts; + using System.Globalization; + using Microsoft.VisualStudio.TestPlatform.Common; + using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; + using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + + internal class InProcessArgumentProcessor : IArgumentProcessor { #region Constants - public const string CommandName = "/NoIsolation"; + public const string CommandName = "/InProcess"; #endregion @@ -31,7 +32,7 @@ public Lazy Metadata { if (this.metadata == null) { - this.metadata = new Lazy(() => new NoIsolationArgumentProcessorCapabilities()); + this.metadata = new Lazy(() => new InProcessArgumentProcessorCapabilities()); } return this.metadata; @@ -47,7 +48,7 @@ public Lazy Executor { if (this.executor == null) { - this.executor = new Lazy(() => new NoIsolationArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); + this.executor = new Lazy(() => new InProcessArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); } return this.executor; @@ -60,9 +61,9 @@ public Lazy Executor } } - internal class NoIsolationArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities + internal class InProcessArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities { - public override string CommandName => NoIsolationArgumentProcessor.CommandName; + public override string CommandName => InProcessArgumentProcessor.CommandName; public override bool AllowMultiple => false; @@ -70,12 +71,12 @@ internal class NoIsolationArgumentProcessorCapabilities : BaseArgumentProcessorC public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; - public override string HelpContentResourceName => "Help message for NoIsolation"; + public override string HelpContentResourceName => CommandLineResources.InProcessHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.NoIsolationArgumentProcessorHelpPriority; + public override HelpContentPriority HelpPriority => HelpContentPriority.InProcessArgumentProcessorHelpPriority; } - internal class NoIsolationArgumentExecutor : IArgumentExecutor + internal class InProcessArgumentExecutor : IArgumentExecutor { #region Fields @@ -86,7 +87,7 @@ internal class NoIsolationArgumentExecutor : IArgumentExecutor private IRunSettingsProvider runSettingsManager; - public const string RunSettingsPath = "RunConfiguration.NoIsolation"; + public const string RunSettingsPath = "RunConfiguration.InProcess"; #endregion @@ -97,7 +98,7 @@ internal class NoIsolationArgumentExecutor : IArgumentExecutor /// /// The options. /// The runsettings manager. - public NoIsolationArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) + public InProcessArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) { Contract.Requires(options != null); Contract.Requires(runSettingsManager != null); @@ -115,23 +116,24 @@ public NoIsolationArgumentExecutor(CommandLineOptions options, IRunSettingsProvi /// Argument that was provided with the command. public void Initialize(string argument) { - // NoIsolation does not require any argument, throws exception if argument specified + // InProcess does not require any argument, throws exception if argument specified if (!string.IsNullOrWhiteSpace(argument)) { throw new CommandLineException( - string.Format(CultureInfo.CurrentCulture, "Place holder for error mesaage", argument)); + string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidInProcessCommand, argument)); } - commandLineOptions.NoIsolation = true; - this.runSettingsManager.UpdateRunSettingsNode(NoIsolationArgumentExecutor.RunSettingsPath, "true"); + commandLineOptions.InProcess = true; + this.runSettingsManager.UpdateRunSettingsNode(InProcessArgumentExecutor.RunSettingsPath, "true"); } /// - /// The output path is already set, return success. + /// Execute argument processor /// /// The Success public ArgumentProcessorResult Execute() { + // Nothing to do here, the work was done in initialization. return ArgumentProcessorResult.Success; } diff --git a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs index c1db8a84b2..237eea18a1 100644 --- a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs @@ -199,7 +199,7 @@ private bool RunTests(IEnumerable sources) GenerateFakesUtilities.GenerateFakesSettings(this.commandLineOptions, this.commandLineOptions.Sources.ToList(), ref runSettings); var runRequestPayload = new TestRunRequestPayload() { Sources = this.commandLineOptions.Sources.ToList(), RunSettings = runSettings, KeepAlive = keepAlive }; - var result = this.testRequestManager.RunTests(runRequestPayload, null, null, Constants.DefaultProtocolConfig); + var result = this.testRequestManager.RunTests(runRequestPayload, null, this.testRunEventsRegistrar, Constants.DefaultProtocolConfig); if (EqtTrace.IsInfoEnabled) { diff --git a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs index 9f6bb6d156..21d1a67f0f 100644 --- a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs +++ b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs @@ -228,7 +228,7 @@ public IEnumerable GetArgumentProcessorsToAlwaysExecute() new FrameworkArgumentProcessor(), new EnableLoggerArgumentProcessor(), new ParallelArgumentProcessor(), - new NoIsolationArgumentProcessor(), + new InProcessArgumentProcessor(), new EnableDiagArgumentProcessor(), new CLIRunSettingsArgumentProcessor(), new ResultsDirectoryArgumentProcessor(), diff --git a/src/vstest.console/Processors/Utilities/HelpContentPriority.cs b/src/vstest.console/Processors/Utilities/HelpContentPriority.cs index 391a0a7f9f..d4568f4245 100644 --- a/src/vstest.console/Processors/Utilities/HelpContentPriority.cs +++ b/src/vstest.console/Processors/Utilities/HelpContentPriority.cs @@ -88,9 +88,9 @@ internal enum HelpContentPriority ParallelArgumentProcessorHelpPriority, /// - /// NoIsolationArgumentProcessor Help + /// InProcessArgumentProcessor Help /// - NoIsolationArgumentProcessorHelpPriority, + InProcessArgumentProcessorHelpPriority, /// /// TestAdapterPathArgumentProcessor Help diff --git a/src/vstest.console/Resources/Resources.Designer.cs b/src/vstest.console/Resources/Resources.Designer.cs index 533a0f49e1..cea3bd2597 100644 --- a/src/vstest.console/Resources/Resources.Designer.cs +++ b/src/vstest.console/Resources/Resources.Designer.cs @@ -692,6 +692,19 @@ public static string InIsolationHelp } } + /// + /// Looks up a localized string similar to --InProcess|/InProcess + /// Runs the tests in vstest.console.exe process. + /// This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + /// + public static string InProcessHelp + { + get + { + return ResourceManager.GetString("InProcessHelp", resourceCulture); + } + } + /// /// Looks up a localized string similar to Invalid batch size {0}. The batch size should be greater than zero. Example: /BatchSize:10. /// @@ -758,6 +771,17 @@ public static string InvalidParallelCommand } } + /// + /// Looks up a localized string similar to Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again.. + /// + public static string InvalidInProcessCommand + { + get + { + return ResourceManager.GetString("InvalidInProcessCommand", resourceCulture); + } + } + /// /// Looks up a localized string similar to The --ParentProcessId|/ParentProcessId argument requires the process id which is an integer. Specify the process id of the parent process that launched this process.. /// diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index 88d1932b17..5c14c856f3 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -675,4 +675,12 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index f35c3813c5..a4bebed601 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -1586,6 +1586,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index 686c80c5b8..bfdd2dfb08 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -1586,6 +1586,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index 8c23b113a4..485697ac05 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -1594,6 +1594,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index f83a61ba30..3b9072bdfe 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -1586,6 +1586,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index 288582fe5d..64d5676ce6 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -1586,6 +1586,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index cd4765a516..fc25eec51b 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -1586,6 +1586,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index a0632ee708..a417b0f9ed 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -1586,6 +1586,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index 54204618f7..5c73722b0a 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -1586,6 +1586,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index 8994a3cabd..d7aca27f55 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -1585,6 +1585,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index 736522a124..caab58577a 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -1587,6 +1587,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index 846eed316f..d2ceca0e03 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -1586,6 +1586,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index fb82140277..47431f216a 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -734,6 +734,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index 4e99612a93..23e03ae8d7 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -1585,6 +1585,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index 51f3c4f29a..bebc51ee26 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -1586,6 +1586,20 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. + + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + --InProcess|/InProcess + Runs the tests in vstest.console.exe process. + This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. + + + + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. + + \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs new file mode 100644 index 0000000000..333ea378a0 --- /dev/null +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace TestPlatform.CrossPlatEngine.UnitTests.Client +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading; + using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using Moq; + + [TestClass] + public class InProcessProxyDiscoveryManagerTests + { + private Mock mockTestHostManagerFactory; + private InProcessProxyDiscoveryManager inProcessProxyDiscoveryManager; + private Mock mockDiscoveryManager; + + [TestInitialize] + public void TestInitialize() + { + this.mockTestHostManagerFactory = new Mock(); + this.mockDiscoveryManager = new Mock(); + this.inProcessProxyDiscoveryManager = new InProcessProxyDiscoveryManager(this.mockTestHostManagerFactory.Object); + + this.mockTestHostManagerFactory.Setup(o => o.GetDiscoveryManager()).Returns(this.mockDiscoveryManager.Object); + } + + [TestCleanup] + public void TestCleanup() + { + this.mockDiscoveryManager = null; + this.mockTestHostManagerFactory = null; + this.inProcessProxyDiscoveryManager = null; + } + + [TestMethod] + public void InitializeShouldCallDiscoveryManagerInitializeWithEmptyIEnumerable() + { + this.inProcessProxyDiscoveryManager.Initialize(); + this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + } + + [TestMethod] + public void InitializeShouldSetIsInitializedTotrue() + { + this.inProcessProxyDiscoveryManager.Initialize(); + Assert.IsTrue(this.inProcessProxyDiscoveryManager.IsInitialized); + } + + [TestMethod] + public void InitializeShouldCallDiscoveryManagerInitializeWithEmptyIEnumerableOnlyOnce() + { + this.inProcessProxyDiscoveryManager.Initialize(); + this.inProcessProxyDiscoveryManager.Initialize(); + this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + } + + [TestMethod] + public void DiscoverTestsShouldCallInitializeIfNotAlreadyInitialized() + { + var manualResetEvent = new ManualResetEvent(true); + + this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty())).Callback( + () => manualResetEvent.Set()); + + this.inProcessProxyDiscoveryManager.DiscoverTests(null, null); + + Assert.IsTrue(manualResetEvent.WaitOne(5000)); + } + + [TestMethod] + public void DiscoverTestsShouldNotCallInitializeIfAlreadyInitialized() + { + var manualResetEvent = new ManualResetEvent(true); + + this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty())).Callback( + () => manualResetEvent.Set()); + + this.inProcessProxyDiscoveryManager.Initialize(); + this.inProcessProxyDiscoveryManager.DiscoverTests(null, null); + + Assert.IsTrue(manualResetEvent.WaitOne(5000)); + this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + } + + [TestMethod] + public void DiscoverTestsShouldCallDiscoveryManagerDiscoverTests() + { + var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); + var mockTestDiscoveryEventsHandler = new Mock(); + var manualResetEvent = new ManualResetEvent(true); + + this.mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( + () => manualResetEvent.Set()); + + this.inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IDiscoveryManager.DiscoverTests should get called"); + } + + [TestMethod] + public void DiscoverTestsShouldCatchExceptionAndCallHandleDiscoveryComplete() + { + var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); + var mockTestDiscoveryEventsHandler = new Mock(); + var manualResetEvent = new ManualResetEvent(true); + + this.mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( + () => throw new Exception()); + + mockTestDiscoveryEventsHandler.Setup(o => o.HandleDiscoveryComplete(-1, It.IsAny>(), true)).Callback( + () => manualResetEvent.Set()); + + this.inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "ITestDiscoveryEventsHandler.HandleDiscoveryComplete should get called"); + } + + [TestMethod] + public void AbortShouldCallDiscoveryManagerAbort() + { + var manualResetEvent = new ManualResetEvent(true); + + this.mockDiscoveryManager.Setup(o => o.Abort()).Callback( + () => manualResetEvent.Set()); + + this.inProcessProxyDiscoveryManager.Abort(); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IDiscoveryManager.Abort should get called"); + } + } +} diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs new file mode 100644 index 0000000000..c93a9242f5 --- /dev/null +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace TestPlatform.CrossPlatEngine.UnitTests.Client +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading; + using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using Moq; + + [TestClass] + public class InProcessProxyExecutionManagerTests + { + private Mock mockTestHostManagerFactory; + private InProcessProxyExecutionManager inProcessProxyExecutionManager; + private Mock mockExecutionManager; + + [TestInitialize] + public void TestInitialize() + { + this.mockTestHostManagerFactory = new Mock(); + this.mockExecutionManager = new Mock(); + this.inProcessProxyExecutionManager = new InProcessProxyExecutionManager(this.mockTestHostManagerFactory.Object); + + this.mockTestHostManagerFactory.Setup(o => o.GetExecutionManager()).Returns(this.mockExecutionManager.Object); + } + + [TestCleanup] + public void TestCleanup() + { + this.mockExecutionManager = null; + this.mockTestHostManagerFactory = null; + this.inProcessProxyExecutionManager = null; + } + + [TestMethod] + public void InitializeShouldCallExecutionManagerInitializeWithEmptyIEnumerable() + { + this.inProcessProxyExecutionManager.Initialize(); + this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + } + + [TestMethod] + public void InitializeShouldSetIsInitializedTotrue() + { + this.inProcessProxyExecutionManager.Initialize(); + Assert.IsTrue(this.inProcessProxyExecutionManager.IsInitialized); + } + + [TestMethod] + public void InitializeShouldCallExecutionManagerInitializeWithEmptyIEnumerableOnlyOnce() + { + this.inProcessProxyExecutionManager.Initialize(); + this.inProcessProxyExecutionManager.Initialize(); + this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + } + + [TestMethod] + public void StartTestRunShouldCallInitializeIfNotAlreadyInitialized() + { + var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); + this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); + + this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + } + + [TestMethod] + public void StartTestRunShouldNotCallInitializeIfAlreadyInitialized() + { + var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); + this.inProcessProxyExecutionManager.Initialize(); + this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); + + this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + } + + [TestMethod] + public void StartTestRunShouldCallExecutionManagerStartTestRunWithAdapterSourceMap() + { + var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); + var manualResetEvent = new ManualResetEvent(true); + + this.mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.AdapterSourceMap, testRunCriteria.TestRunSettings, It.IsAny(), null, null)).Callback( + () => manualResetEvent.Set()); + + this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); + } + + [TestMethod] + public void StartTestRunShouldCallExecutionManagerStartTestRunWithTestCase() + { + var testRunCriteria = new TestRunCriteria( + new List { new TestCase("A.C.M", new Uri("excutor://dummy"), "s.dll") }, + frequencyOfRunStatsChangeEvent: 10); + var manualResetEvent = new ManualResetEvent(true); + + this.mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests, testRunCriteria.TestRunSettings, It.IsAny(), null, null)).Callback( + () => manualResetEvent.Set()); + + this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); + } + + [TestMethod] + public void StartTestRunShouldCatchExceptionAndCallHandleRunComplete() + { + var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); + var mockTestRunEventsHandler = new Mock(); + var manualResetEvent = new ManualResetEvent(true); + + this.mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.AdapterSourceMap, testRunCriteria.TestRunSettings, It.IsAny(), null, mockTestRunEventsHandler.Object)).Callback( + () => throw new Exception()); + + mockTestRunEventsHandler.Setup(o => o.HandleTestRunComplete(It.IsAny(), null, null, null)).Callback( + () => manualResetEvent.Set()); + + this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, mockTestRunEventsHandler.Object); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "ITestRunEventsHandler.HandleTestRunComplete should get called"); + } + + [TestMethod] + public void AbortShouldCallExecutionManagerAbort() + { + var manualResetEvent = new ManualResetEvent(true); + + this.mockExecutionManager.Setup(o => o.Abort()).Callback( + () => manualResetEvent.Set()); + + this.inProcessProxyExecutionManager.Abort(); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.Abort should get called"); + } + + [TestMethod] + public void CancelShouldCallExecutionManagerCancel() + { + var manualResetEvent = new ManualResetEvent(true); + + this.mockExecutionManager.Setup(o => o.Cancel()).Callback( + () => manualResetEvent.Set()); + + this.inProcessProxyExecutionManager.Cancel(); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.Abort should get called"); + } + } +} diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs index e995bfa85b..a3d82c2506 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs @@ -12,24 +12,34 @@ namespace TestPlatform.CrossPlatEngine.UnitTests using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; + using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; using Microsoft.VisualStudio.TestTools.UnitTesting; - + using Moq; using TestPlatform.Common.UnitTests.ExtensionFramework; [TestClass] public class TestEngineTests { private ITestEngine testEngine; + private Mock mockProcessHelper; private ProtocolConfig protocolConfig = new ProtocolConfig { Version = 1 }; private ITestRuntimeProvider testableTestRuntimeProvider; public TestEngineTests() { TestPluginCacheTests.SetupMockExtensions(new[] { typeof(TestEngineTests).GetTypeInfo().Assembly.Location }, () => { }); - this.testEngine = new TestableTestEngine(); + this.mockProcessHelper = new Mock(); + this.mockProcessHelper.Setup(o => o.GetCurrentProcessFileName()).Returns("vstest.console"); + this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object); this.testableTestRuntimeProvider = new TestableRuntimeProvider(true); } + [TestCleanup] + public void TestCleanup() + { + this.mockProcessHelper.Setup(o => o.GetCurrentProcessFileName()).Returns("vstest.console"); + } + [TestMethod] public void GetDiscoveryManagerShouldReturnANonNullInstance() { @@ -57,6 +67,117 @@ public void GetDiscoveryManagerShouldReturnsParallelDiscoveryManagerIfTestHostIs Assert.IsInstanceOfType(this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig), typeof(ParallelProxyDiscoveryManager)); } + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfCurrentProcessIsDotnet() + { + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, null); + this.mockProcessHelper.Setup(o => o.GetCurrentProcessFileName()).Returns("dotnet.exe"); + + var discoveryManager = this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } + + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfDisableAppDomainIsSet() + { + string settingXml = + @" + + true + true + true + .NETFramework, Version=v4.5 + + "; + + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + + var discoveryManager = this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } + + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfDesignModeIsTrue() + { + string settingXml = + @" + + true + false + true + .NETFramework, Version=v4.5 + + "; + + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + + var discoveryManager = this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } + + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIfTargetFrameworkIsNetcoreApp() + { + string settingXml = + @" + + true + false + false + .NETCoreApp, Version=v1.1 + + "; + + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + + var discoveryManager = this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } + + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIfTargetFrameworkIsNetStandard() + { + string settingXml = + @" + + true + false + false + .NETStandard, Version=v1.4 + + "; + + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + + var discoveryManager = this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } + + [TestMethod] + public void GetDiscoveryManagerShouldReturnsInProcessProxyDiscoveryManager() + { + string settingXml = + @" + + true + false + false + .NETFramework, Version=v4.5 + + "; + + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + + var discoveryManager = this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig); + Assert.IsNotNull(discoveryManager); + Assert.IsInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } + [TestMethod] public void GetExecutionManagerShouldReturnANonNullInstance() { @@ -125,6 +246,78 @@ public void GetExcecutionManagerShouldReturnExectuionManagerWithDataCollectionIf Assert.IsInstanceOfType(result, typeof(ProxyExecutionManagerWithDataCollection)); } + [TestMethod] + public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfParallelEnabled() + { + string settingXml = + @" + + true + false + false + .NETFramework, Version=v4.5 + 2 + + "; + + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + + var executionManager = this.testEngine.GetExecutionManager(this.testableTestRuntimeProvider, testRunCriteria, this.protocolConfig); + + Assert.IsNotNull(executionManager); + Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); + } + + [TestMethod] + public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfDataCollectorIsEnabled() + { + string settingXml = + @" + + true + false + false + .NETFramework, Version=v4.5 + 1 + + + + + + + + "; + + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + + var executionManager = this.testEngine.GetExecutionManager(this.testableTestRuntimeProvider, testRunCriteria, this.protocolConfig); + + Assert.IsNotNull(executionManager); + Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); + } + + [TestMethod] + public void GetExecutionManagerShouldReturnInProcessProxyexecutionManager() + { + string settingXml = + @" + + true + false + false + .NETFramework, Version=v4.5 + 1 + + "; + + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + + var executionManager = this.testEngine.GetExecutionManager(this.testableTestRuntimeProvider, testRunCriteria, this.protocolConfig); + + Assert.IsNotNull(executionManager); + Assert.IsInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); + } + [TestMethod] public void GetExtensionManagerShouldReturnANonNullInstance() { diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs index ddb2dde5a2..e2bf3791a7 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs @@ -5,11 +5,13 @@ namespace TestPlatform.CrossPlatEngine.UnitTests { using Microsoft.VisualStudio.TestPlatform.Common.Hosting; using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; + using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; public class TestableTestEngine : TestEngine { - public TestableTestEngine() - : base(TestRuntimeProviderManager.Instance) + public TestableTestEngine(IProcessHelper processHelper) + : base(TestRuntimeProviderManager.Instance, processHelper) { } } diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs index ba6b2430f6..0e3ed7ab67 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs @@ -32,6 +32,7 @@ public void RunConfigurationDefaultValuesMustBeUsedOnCreation() Assert.AreEqual(Constants.DefaultCpuCount, runConfiguration.MaxCpuCount); Assert.AreEqual(false, runConfiguration.DisableAppDomain); Assert.AreEqual(false, runConfiguration.DisableParallelization); + Assert.AreEqual(false, runConfiguration.InProcess); Assert.AreEqual(false, runConfiguration.DesignMode); Assert.AreEqual(runConfiguration.DesignMode, runConfiguration.ShouldCollectSourceInformation); Assert.AreEqual(Constants.DefaultExecutionThreadApartmentState, runConfiguration.ExecutionThreadApartmentState); @@ -69,6 +70,7 @@ public void RunConfigurationReadsValuesCorrectlyFromXml() true true true + true 2 5 10000 @@ -103,6 +105,7 @@ public void RunConfigurationReadsValuesCorrectlyFromXml() Assert.AreEqual(10000, runConfiguration.TestSessionTimeout); Assert.AreEqual(true, runConfiguration.DisableAppDomain); Assert.AreEqual(true, runConfiguration.DisableParallelization); + Assert.AreEqual(true, runConfiguration.InProcess); Assert.AreEqual(true, runConfiguration.DesignMode); Assert.AreEqual(false, runConfiguration.ShouldCollectSourceInformation); Assert.AreEqual(PlatformApartmentState.STA, runConfiguration.ExecutionThreadApartmentState); diff --git a/test/vstest.console.UnitTests/Processors/InProcessArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/InProcessArgumentProcessorTests.cs new file mode 100644 index 0000000000..0ae25b68b5 --- /dev/null +++ b/test/vstest.console.UnitTests/Processors/InProcessArgumentProcessorTests.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +{ + using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using TestPlatform.CommandLine.Processors; + using vstest.console.UnitTests.Processors; + + [TestClass] + public class InProcessArgumentProcessorTests + { + private InProcessArgumentExecutor executor; + private TestableRunSettingsProvider runSettingsProvider; + + [TestInitialize] + public void Init() + { + this.runSettingsProvider = new TestableRunSettingsProvider(); + this.executor = new InProcessArgumentExecutor(CommandLineOptions.Instance, this.runSettingsProvider); + } + [TestCleanup] + public void TestCleanup() + { + CommandLineOptions.Instance.Reset(); + } + + [TestMethod] + public void GetMetadataShouldReturnInProcessArgumentProcessorCapabilities() + { + var processor = new InProcessArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is InProcessArgumentProcessorCapabilities); + } + + [TestMethod] + public void GetExecuterShouldReturnInProcessArgumentExecutor() + { + var processor = new InProcessArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is InProcessArgumentExecutor); + } + + #region InProcessArgumentProcessorCapabilities tests + + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new InProcessArgumentProcessorCapabilities(); + Assert.AreEqual("/InProcess", capabilities.CommandName); + Assert.AreEqual("--InProcess|/InProcess\n Runs the tests in vstest.console.exe process.\n This is supported for framework \".NETFramework,Version=v4.*\", Framework40 and Framework45.", capabilities.HelpContentResourceName); + + Assert.AreEqual(HelpContentPriority.InProcessArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.AreEqual(false, capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); + + Assert.AreEqual(false, capabilities.AllowMultiple); + Assert.AreEqual(false, capabilities.AlwaysExecute); + Assert.AreEqual(false, capabilities.IsSpecialCommand); + } + + #endregion + + #region InProcessArgumentExecutor Initialize tests + + [TestMethod] + public void InitializeShouldThrowIfArgumentIsNonNull() + { + // InProcess should not have any values or arguments + ExceptionUtilities.ThrowsException( + () => this.executor.Initialize("true"), + "Argument " + "true" + " is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again."); + } + + [TestMethod] + public void InitializeShouldSetInProcessValue() + { + this.executor.Initialize(null); + Assert.IsTrue(CommandLineOptions.Instance.InProcess, "InProcess option must be set to true."); + Assert.AreEqual("true", this.runSettingsProvider.QueryRunSettingsNode(InProcessArgumentExecutor.RunSettingsPath)); + } + + #endregion + + #region InProcessArgumentExecutor Execute tests + + [TestMethod] + public void ExecuteShouldReturnSuccess() + { + Assert.AreEqual(ArgumentProcessorResult.Success, this.executor.Execute()); + } + + #endregion + } +} From 2f76f3c93cbcd975b1ef55ef51aef63e35dc9257 Mon Sep 17 00:00:00 2001 From: faahmad Date: Fri, 25 Aug 2017 20:43:07 +0530 Subject: [PATCH 5/8] 1) Making in process default for net46 2) Enable InIsolation argument to disable default in process. 3) Address PR comment --- .../TestPlatform.cs | 3 +- .../TestPlatformFactory.cs | 4 +- .../Client/InProcessProxyDiscoveryManager.cs | 19 +-- .../Client/InProcessProxyexecutionManager.cs | 21 ++- .../Discovery/DiscoveryManager.cs | 2 +- .../Execution/ExecutionManager.cs | 2 +- .../TestEngine.cs | 41 +++-- .../RunSettings/RunConfiguration.cs | 49 ------ .../CommandLine/CommandLineOptions.cs | 4 +- .../InIsolationArgumentProcessor.cs | 12 +- .../Processors/InProcessArgumentProcessor.cs | 142 ------------------ .../Utilities/ArgumentProcessorFactory.cs | 1 - .../Utilities/HelpContentPriority.cs | 5 - .../Resources/Resources.Designer.cs | 24 --- src/vstest.console/Resources/Resources.resx | 10 +- .../Resources/xlf/Resources.cs.xlf | 20 +-- .../Resources/xlf/Resources.de.xlf | 20 +-- .../Resources/xlf/Resources.es.xlf | 20 +-- .../Resources/xlf/Resources.fr.xlf | 20 +-- .../Resources/xlf/Resources.it.xlf | 20 +-- .../Resources/xlf/Resources.ja.xlf | 20 +-- .../Resources/xlf/Resources.ko.xlf | 20 +-- .../Resources/xlf/Resources.pl.xlf | 20 +-- .../Resources/xlf/Resources.pt-BR.xlf | 20 +-- .../Resources/xlf/Resources.ru.xlf | 20 +-- .../Resources/xlf/Resources.tr.xlf | 20 +-- .../Resources/xlf/Resources.xlf | 16 +- .../Resources/xlf/Resources.zh-Hans.xlf | 20 +-- .../Resources/xlf/Resources.zh-Hant.xlf | 20 +-- .../TestPlatformHelpers/TestRequestManager.cs | 2 +- .../InProcessProxyDiscoveryManagerTests.cs | 13 +- .../InProcessProxyexecutionManagerTests.cs | 13 +- .../TestEngineTests.cs | 71 +++++++-- .../TestableTestEngine.cs | 4 +- .../RunSettings/RunConfigurationTests.cs | 3 - .../InIsolationArgumentProcessorTests.cs | 72 ++++++--- .../InProcessArgumentProcessorTests.cs | 94 ------------ 37 files changed, 230 insertions(+), 657 deletions(-) delete mode 100644 src/vstest.console/Processors/InProcessArgumentProcessor.cs delete mode 100644 test/vstest.console.UnitTests/Processors/InProcessArgumentProcessorTests.cs diff --git a/src/Microsoft.TestPlatform.Client/TestPlatform.cs b/src/Microsoft.TestPlatform.Client/TestPlatform.cs index f9cdd303ce..df68fc92cb 100644 --- a/src/Microsoft.TestPlatform.Client/TestPlatform.cs +++ b/src/Microsoft.TestPlatform.Client/TestPlatform.cs @@ -46,7 +46,8 @@ static TestPlatform() /// /// Initializes a new instance of the class. /// - public TestPlatform() : this(new TestEngine(), new FileHelper(), TestRuntimeProviderManager.Instance) + /// inIsolation command line arg value + public TestPlatform(bool isInIsolation = false) : this(new TestEngine(isInIsolation), new FileHelper(), TestRuntimeProviderManager.Instance) { } diff --git a/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs b/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs index 44ffa5e33f..4f1bf0e04f 100644 --- a/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs +++ b/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs @@ -16,9 +16,9 @@ public class TestPlatformFactory /// Gets an instance of the test platform. /// /// The instance. - public static ITestPlatform GetTestPlatform() + public static ITestPlatform GetTestPlatform(bool isInIsolation) { - return testPlatform ?? (testPlatform = new TestPlatform()); + return testPlatform ?? (testPlatform = new TestPlatform(isInIsolation)); } } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs index 67725b50cd..bbfba3f2ec 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs @@ -13,9 +13,10 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - class InProcessProxyDiscoveryManager : IProxyDiscoveryManager + internal class InProcessProxyDiscoveryManager : IProxyDiscoveryManager { private ITestHostManagerFactory testHostManagerFactory; + IDiscoveryManager discoveryManager; public bool IsInitialized { get; private set; } = false; /// @@ -32,6 +33,7 @@ public InProcessProxyDiscoveryManager() : this(new TestHostManagerFactory()) internal InProcessProxyDiscoveryManager(ITestHostManagerFactory testHostManagerFactory) { this.testHostManagerFactory = testHostManagerFactory; + this.discoveryManager = this.testHostManagerFactory.GetDiscoveryManager(); } /// @@ -41,11 +43,9 @@ public void Initialize() { if(!this.IsInitialized) { - var discoveryManager = this.testHostManagerFactory.GetDiscoveryManager(); - // We don't need to pass list of extension as we are running inside vstest.console and // it will use TestPluginCache of vstest.console - discoveryManager.Initialize(Enumerable.Empty()); + this.discoveryManager.Initialize(Enumerable.Empty()); this.IsInitialized = true; } } @@ -57,25 +57,20 @@ public void Initialize() /// EventHandler for handling discovery events from Engine public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler eventHandler) { - var discoveryManager = this.testHostManagerFactory.GetDiscoveryManager(); - Task.Run(() => { try { // Initialize extension before discovery if it’s not initialized - if (!this.IsInitialized) - { - discoveryManager.Initialize(Enumerable.Empty()); - } - discoveryManager.DiscoverTests(discoveryCriteria, eventHandler); + this.Initialize(); + this.discoveryManager.DiscoverTests(discoveryCriteria, eventHandler); } catch (Exception exception) { EqtTrace.Error("InProcessProxyDiscoveryManager.DiscoverTests: Failed to discover tests: {0}", exception); // Send a discovery complete to caller. - eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.Message); + eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.ToString()); eventHandler.HandleDiscoveryComplete(-1, new List(), true); } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs index ac3a76e50d..991198cc61 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs @@ -14,9 +14,10 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - class InProcessProxyExecutionManager : IProxyExecutionManager + internal class InProcessProxyExecutionManager : IProxyExecutionManager { private ITestHostManagerFactory testHostManagerFactory; + IExecutionManager executionManager; public bool IsInitialized { get; private set; } = false; /// @@ -35,14 +36,16 @@ public InProcessProxyExecutionManager() : this(new TestHostManagerFactory()) internal InProcessProxyExecutionManager(ITestHostManagerFactory testHostManagerFactory) { this.testHostManagerFactory = testHostManagerFactory; + this.executionManager = this.testHostManagerFactory.GetExecutionManager(); } + /// + /// Initialize adapters. + /// public void Initialize() { if (!this.IsInitialized) { - var executionManager = this.testHostManagerFactory.GetExecutionManager(); - // We don't need to pass list of extension as we are running inside vstest.console and // it will use TestPluginCache of vstest.console executionManager.Initialize(Enumerable.Empty()); @@ -50,17 +53,13 @@ public void Initialize() } } + /// public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) { try { - var executionManager = this.testHostManagerFactory.GetExecutionManager(); - // Initialize extension before execution if not already initialized - if (!this.IsInitialized) - { - executionManager.Initialize(Enumerable.Empty()); - } + this.Initialize(); var executionContext = new TestExecutionContext( testRunCriteria.FrequencyOfRunStatsChangeEvent, @@ -89,8 +88,8 @@ public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler e { EqtTrace.Error("InProcessProxyexecutionManager.StartTestRun: Failed to start test run: {0}", exception); - // Send a discovery complete to caller. - eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.Message); + // Send exception message. + eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.ToString()); // Send a run complete to caller. var completeArgs = new TestRunCompleteEventArgs(null, false, true, exception, new Collection(), TimeSpan.Zero); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs index 5f60516a47..3d32f54c96 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs @@ -60,7 +60,7 @@ public void Initialize(IEnumerable pathToAdditionalExtensions) { this.testPlatformEventSource.AdapterSearchStart(); - if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Count() > 0) + if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Any()) { // Start using these additional extensions TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions; diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs index fa90e833ff..aa8d2c97fa 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs @@ -53,7 +53,7 @@ public void Initialize(IEnumerable pathToAdditionalExtensions) { this.testPlatformEventSource.AdapterSearchStart(); - if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Count() > 0) + if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Any()) { // Start using these additional extensions TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions; diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs index c08b2df22e..a2d0bc1f5b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs @@ -31,17 +31,19 @@ public class TestEngine : ITestEngine private readonly TestRuntimeProviderManager testHostProviderManager; private ITestExtensionManager testExtensionManager; private IProcessHelper processHelper; + private bool isInIsolation = false; #endregion - public TestEngine() : this(TestRuntimeProviderManager.Instance, new ProcessHelper()) + public TestEngine(bool isInIsolation = false) : this(TestRuntimeProviderManager.Instance, new ProcessHelper(), isInIsolation) { } - protected TestEngine(TestRuntimeProviderManager testHostProviderManager, IProcessHelper processHelper) + protected TestEngine(TestRuntimeProviderManager testHostProviderManager, IProcessHelper processHelper, bool isInIsolation) { this.testHostProviderManager = testHostProviderManager; this.processHelper = processHelper; + this.isInIsolation = isInIsolation; } #region ITestEngine implementation @@ -63,7 +65,7 @@ public IProxyDiscoveryManager GetDiscoveryManager(ITestRuntimeProvider testHostM { var parallelLevel = this.VerifyParallelSettingAndCalculateParallelLevel(discoveryCriteria.Sources.Count(), discoveryCriteria.RunSettings); - if (this.ShouldRunInNoIsolation(discoveryCriteria.RunSettings)) + if (this.ShouldRunInNoIsolation(discoveryCriteria.RunSettings, parallelLevel > 1, false)) { return new InProcessProxyDiscoveryManager(); } @@ -95,7 +97,7 @@ public IProxyExecutionManager GetExecutionManager(ITestRuntimeProvider testHostM var isDataCollectorEnabled = XmlRunSettingsUtilities.IsDataCollectionEnabled(testRunCriteria.TestRunSettings); - if (parallelLevel <= 1 && !isDataCollectorEnabled && this.ShouldRunInNoIsolation(testRunCriteria.TestRunSettings)) + if (this.ShouldRunInNoIsolation(testRunCriteria.TestRunSettings, parallelLevel > 1, isDataCollectorEnabled)) { return new InProcessProxyExecutionManager(); } @@ -208,11 +210,20 @@ private int VerifyParallelSettingAndCalculateParallelLevel(int sourceCount, stri return parallelLevelToUse; } - private bool ShouldRunInNoIsolation(string runsettings) + private bool ShouldRunInNoIsolation(string runsettings, bool isParallelEnabled, bool isDataCollectorEnabled) { + if(this.isInIsolation == true) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("TestEngine.ShouldRunInNoIsolation: running test in isolation"); + } + return false; + } + var currentProcessPath = this.processHelper.GetCurrentProcessFileName(); - // If running with the dotnet executable, then dont run in NoIsolation + // If running with the dotnet executable, then dont run in InProcess if (currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase) || currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase)) { @@ -221,12 +232,24 @@ private bool ShouldRunInNoIsolation(string runsettings) var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings); - if (runConfiguration.InProcess && + // Return true if + // 1) Not running in parallel + // 2) Data collector is not enabled + // 3) Target framework is x86 or anyCpu + // 4) DisableAppDomain is false + // 5) Not running in design mode + // 6) target framework is NETFramework (Desktop test) + if (!isParallelEnabled && + !isDataCollectorEnabled && + (runConfiguration.TargetPlatform == Architecture.X86 || runConfiguration.TargetPlatform == Architecture.AnyCPU) && !runConfiguration.DisableAppDomain && !runConfiguration.DesignMode && - !(runConfiguration.TargetFrameworkVersion.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 - || runConfiguration.TargetFrameworkVersion.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0)) + runConfiguration.TargetFrameworkVersion.Name.IndexOf("netframework", StringComparison.OrdinalIgnoreCase) >= 0) { + if(EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("TestEngine.ShouldRunInNoIsolation: running test in process(inside vstest.console.exe process)"); + } return true ; } diff --git a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs index 0628a30a75..239813e352 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs @@ -59,11 +59,6 @@ public class RunConfiguration : TestRunSettings /// private bool disableAppDomain; - /// - /// Specify to not run tests in isolation. - /// - private bool inProcess; - /// /// Indication to adapters to disable parallelization. /// @@ -100,7 +95,6 @@ public RunConfiguration() : base(Constants.RunConfigurationSettingsName) this.batchSize = Constants.DefaultBatchSize; this.testSessionTimeout = 0; this.disableAppDomain = false; - this.inProcess = false; this.disableParallelization = false; this.designMode = false; this.shouldCollectSourceInformation = false; @@ -236,23 +230,6 @@ public bool DisableAppDomain } } - /// - /// Gets or sets a value indicating whether to run tests in isolation or not. - /// - public bool InProcess - { - get - { - return this.inProcess; - } - - set - { - this.inProcess = value; - this.InProcessSet = true; - } - } - /// /// Gets a value indicating whether parallelism needs to be disabled by the adapters. /// @@ -398,15 +375,6 @@ public bool DisableAppDomainSet private set; } - /// - /// Gets a value indicating whether InProcess is set. - /// - public bool InProcessSet - { - get; - private set; - } - /// /// Gets a value indicating whether parallelism needs to be disabled by the adapters. /// @@ -496,10 +464,6 @@ public override XmlElement ToXml() disableAppDomain.InnerXml = this.DisableAppDomain.ToString(); root.AppendChild(disableAppDomain); - XmlElement inProcess = doc.CreateElement("InProcess"); - inProcess.InnerXml = this.InProcess.ToString(); - root.AppendChild(inProcess); - XmlElement disableParallelization = doc.CreateElement("DisableParallelization"); disableParallelization.InnerXml = this.DisableParallelization.ToString(); root.AppendChild(disableParallelization); @@ -657,19 +621,6 @@ public static RunConfiguration FromXml(XmlReader reader) runConfiguration.DisableAppDomain = disableAppDomainCheck; break; - case "InProcess": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - - string inProcessValueString = reader.ReadElementContentAsString(); - bool inProcessCheck; - if (!bool.TryParse(inProcessValueString, out inProcessCheck)) - { - throw new SettingsException(String.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, inProcessValueString, elementName)); - } - runConfiguration.InProcess = inProcessCheck; - break; - case "DisableParallelization": XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); diff --git a/src/vstest.console/CommandLine/CommandLineOptions.cs b/src/vstest.console/CommandLine/CommandLineOptions.cs index 132948ffc5..3ad3eff613 100644 --- a/src/vstest.console/CommandLine/CommandLineOptions.cs +++ b/src/vstest.console/CommandLine/CommandLineOptions.cs @@ -98,9 +98,9 @@ protected CommandLineOptions() public bool Parallel { get; set; } /// - /// Specifies whether InProcess is on or off. + /// Specifies whether InIsolation is on or off. /// - public bool InProcess { get; set; } + public bool InIsolation { get; set; } /// /// Readonly collection of all available test sources diff --git a/src/vstest.console/Processors/InIsolationArgumentProcessor.cs b/src/vstest.console/Processors/InIsolationArgumentProcessor.cs index de5693ce61..a1d9a9c01c 100644 --- a/src/vstest.console/Processors/InIsolationArgumentProcessor.cs +++ b/src/vstest.console/Processors/InIsolationArgumentProcessor.cs @@ -3,6 +3,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors { using System; + using System.Diagnostics.Contracts; using System.Globalization; using Microsoft.VisualStudio.TestPlatform.Utilities; using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; @@ -51,7 +52,7 @@ public Lazy Executor this.executor = new Lazy( () => - new InIsolationArgumentExecutor()); + new InIsolationArgumentExecutor(CommandLineOptions.Instance)); } return this.executor; @@ -74,14 +75,19 @@ internal class InIsolationArgumentProcessorCapabilities : BaseArgumentProcessorC public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; + public override string HelpContentResourceName => CommandLineResources.InIsolationHelp; + public override HelpContentPriority HelpPriority => HelpContentPriority.InIsolationArgumentProcessorHelpPriority; } internal class InIsolationArgumentExecutor : IArgumentExecutor { + private CommandLineOptions commandLineOptions; #region Constructors - public InIsolationArgumentExecutor() + public InIsolationArgumentExecutor(CommandLineOptions options) { + Contract.Requires(options != null); + this.commandLineOptions = options; } #endregion @@ -99,7 +105,7 @@ public void Initialize(string argument) string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidInIsolationCommand, argument)); } - ConsoleOutput.Instance.WriteLine(CommandLineResources.InIsolationDeprecated, OutputLevel.Information); + this.commandLineOptions.InIsolation = true; } /// diff --git a/src/vstest.console/Processors/InProcessArgumentProcessor.cs b/src/vstest.console/Processors/InProcessArgumentProcessor.cs deleted file mode 100644 index 8ea735d437..0000000000 --- a/src/vstest.console/Processors/InProcessArgumentProcessor.cs +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Diagnostics.Contracts; - using System.Globalization; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - - internal class InProcessArgumentProcessor : IArgumentProcessor - { - #region Constants - - public const string CommandName = "/InProcess"; - - #endregion - - private Lazy metadata; - - private Lazy executor; - - /// - /// Gets the metadata. - /// - public Lazy Metadata - { - get - { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new InProcessArgumentProcessorCapabilities()); - } - - return this.metadata; - } - } - - /// - /// Gets or sets the executor. - /// - public Lazy Executor - { - get - { - if (this.executor == null) - { - this.executor = new Lazy(() => new InProcessArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); - } - - return this.executor; - } - - set - { - this.executor = value; - } - } - } - - internal class InProcessArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => InProcessArgumentProcessor.CommandName; - - public override bool AllowMultiple => false; - - public override bool IsAction => false; - - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; - - public override string HelpContentResourceName => CommandLineResources.InProcessHelp; - - public override HelpContentPriority HelpPriority => HelpContentPriority.InProcessArgumentProcessorHelpPriority; - } - - internal class InProcessArgumentExecutor : IArgumentExecutor - { - #region Fields - - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; - - private IRunSettingsProvider runSettingsManager; - - public const string RunSettingsPath = "RunConfiguration.InProcess"; - - #endregion - - #region Constructor - - /// - /// Default constructor. - /// - /// The options. - /// The runsettings manager. - public InProcessArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) - { - Contract.Requires(options != null); - Contract.Requires(runSettingsManager != null); - this.commandLineOptions = options; - this.runSettingsManager = runSettingsManager; - } - - #endregion - - #region IArgumentExecutor - - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) - { - // InProcess does not require any argument, throws exception if argument specified - if (!string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException( - string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidInProcessCommand, argument)); - } - - commandLineOptions.InProcess = true; - this.runSettingsManager.UpdateRunSettingsNode(InProcessArgumentExecutor.RunSettingsPath, "true"); - } - - /// - /// Execute argument processor - /// - /// The Success - public ArgumentProcessorResult Execute() - { - // Nothing to do here, the work was done in initialization. - return ArgumentProcessorResult.Success; - } - - #endregion - } -} diff --git a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs index 21d1a67f0f..c7eb830b1e 100644 --- a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs +++ b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs @@ -228,7 +228,6 @@ public IEnumerable GetArgumentProcessorsToAlwaysExecute() new FrameworkArgumentProcessor(), new EnableLoggerArgumentProcessor(), new ParallelArgumentProcessor(), - new InProcessArgumentProcessor(), new EnableDiagArgumentProcessor(), new CLIRunSettingsArgumentProcessor(), new ResultsDirectoryArgumentProcessor(), diff --git a/src/vstest.console/Processors/Utilities/HelpContentPriority.cs b/src/vstest.console/Processors/Utilities/HelpContentPriority.cs index d4568f4245..ee9d1435c3 100644 --- a/src/vstest.console/Processors/Utilities/HelpContentPriority.cs +++ b/src/vstest.console/Processors/Utilities/HelpContentPriority.cs @@ -87,11 +87,6 @@ internal enum HelpContentPriority /// ParallelArgumentProcessorHelpPriority, - /// - /// InProcessArgumentProcessor Help - /// - InProcessArgumentProcessorHelpPriority, - /// /// TestAdapterPathArgumentProcessor Help /// diff --git a/src/vstest.console/Resources/Resources.Designer.cs b/src/vstest.console/Resources/Resources.Designer.cs index cea3bd2597..533a0f49e1 100644 --- a/src/vstest.console/Resources/Resources.Designer.cs +++ b/src/vstest.console/Resources/Resources.Designer.cs @@ -692,19 +692,6 @@ public static string InIsolationHelp } } - /// - /// Looks up a localized string similar to --InProcess|/InProcess - /// Runs the tests in vstest.console.exe process. - /// This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - /// - public static string InProcessHelp - { - get - { - return ResourceManager.GetString("InProcessHelp", resourceCulture); - } - } - /// /// Looks up a localized string similar to Invalid batch size {0}. The batch size should be greater than zero. Example: /BatchSize:10. /// @@ -771,17 +758,6 @@ public static string InvalidParallelCommand } } - /// - /// Looks up a localized string similar to Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again.. - /// - public static string InvalidInProcessCommand - { - get - { - return ResourceManager.GetString("InvalidInProcessCommand", resourceCulture); - } - } - /// /// Looks up a localized string similar to The --ParentProcessId|/ParentProcessId argument requires the process id which is an integer. Specify the process id of the parent process that launched this process.. /// diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index 5c14c856f3..5f12a5d530 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -303,7 +303,7 @@ Hours - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. @@ -675,12 +675,4 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index a4bebed601..9a73cce2b1 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -420,15 +420,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation Spustí testy v izolovaném procesu. Díky tomu je méně pravděpodobné, že se proces vstest.console.exe zastaví, pokud se v testu stane chyba, ale testy můžou být pomalejší. - + / InIsolation Testy běží v izolovaném procesu. Díky tomu je méně pravděpodobné, že má být zastaven v chybě při zkouškách vstest.console.exe procesu, ale zkoušky může pracovat pomaleji. @@ -1586,20 +1586,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index bfdd2dfb08..88e185cd62 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -420,15 +420,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation Führt die Tests in einem isolierten Prozess aus. Auf diese Weise ist es unwahrscheinlicher, dass der Prozess "vstest.console.exe" bei einem Fehler in den Tests beendet wird. Tests werden aber ggf. langsamer ausgeführt. - + / InIsolation Führt Tests in einem isolierten Prozess. Vstest.console.exe wird voraussichtlich auf Fehler in den Tests beendet jedoch Tests möglicherweise langsamer ausgeführt. @@ -1586,20 +1586,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index 485697ac05..665007b856 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -420,16 +420,16 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation Ejecuta las pruebas en un proceso aislado. De ese modo, es menos probable que el proceso vstest.console.exe se detenga ante un error en las pruebas, pero es posible que las pruebas se ejecuten con más lentitud. - + / Siendo Ejecuta las pruebas en un proceso aislado. Esto hace menos probable que se detiene en un error en las pruebas de proceso de vstest.console.exe, pero las pruebas pueden ejecutarse más despacio. @@ -1594,20 +1594,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index 3b9072bdfe..c572b321a4 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -420,15 +420,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation Exécute les tests dans un processus isolé. Le processus vstest.console.exe est moins susceptible de s'arrêter en cas d'erreur durant les tests, mais ces derniers risquent de s'exécuter plus lentement. - + / InIsolation Exécute les tests dans un processus isolé. Processus de vstest.console.exe moins susceptible d’être arrêté sur une erreur dans les tests, mais les tests peuvent s’exécuter plus lentement. @@ -1586,20 +1586,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index 64d5676ce6..03d170b1dd 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -420,15 +420,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation Esegue i test in un processo isolato. In questo modo è meno probabile che il processo vstest.console.exe venga arrestato in caso di errore nei test, che però potrebbero risultare più lenti. - + / InIsolation Esegue i test in un processo isolato. Ciò rende meno probabile che l'interruzione di un errore nei test di processo vstest.console.exe, ma i test possono essere eseguite più lentamente. @@ -1586,20 +1586,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index fc25eec51b..39cee67f96 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -420,15 +420,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation 分離プロセスでテストを実行します。これにより、vstest.console.exe プロセスがテスト時にエラーで停止する可能性は低くなりますが、 テストの速度が遅くなる場合があります。 - + /InIsolation 分離プロセスでテストを実行します。これは、ため、vstest.console.exe プロセスを停止、テストでエラーが発生する可能性が低く、テストの実行速度が低下する可能性があります。 @@ -1586,20 +1586,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index a417b0f9ed..30812827c3 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -420,15 +420,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation 격리 모드에서 테스트를 실행합니다. 이렇게 하면 테스트에서 오류가 발생해도 vstest.console.exe가 중지될 가능성이 작아지지만 테스트 실행 속도가 느려질 수 있습니다. - + / InIsolation 격리 된 프로세스에서 테스트를 실행 합니다. 이렇게 하면 vstest.console.exe 프로세스 테스트에서는 오류로 중지 될 가능성이 적은 있지만 테스트 다소 느려질 수 있습니다. @@ -1586,20 +1586,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index 5c73722b0a..06670f1e87 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -420,15 +420,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation Uruchamia testy w procesie izolowanym. Dzięki temu mniej prawdopodobne jest zatrzymanie procesu vstest.console.exe po wystąpieniu błędu w testach, ale testy mogą działać wolniej. - + / InIsolation Uruchamia testy w procesie izolowanym. Dzięki temu mniej prawdopodobne, aby zatrzymać się na błąd w badaniach procesu vstest.console.exe, ale badania może działać wolniej. @@ -1586,20 +1586,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index d7aca27f55..fa401cad0c 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -419,15 +419,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation Executa os testes em um processo isolado. Isso diminui a probabilidade de que o processo vstest.console.exe seja interrompido em um erro nos testes, mas os testes podem ficar mais lentos. - + / InIsolation Executa os testes em um processo isolado. Isso torna o processo de vstest.console.exe menos probabilidade de ser interrompido em um erro nos testes, mas os testes podem ser executados mais lentamente. @@ -1585,20 +1585,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index caab58577a..00bf7b4ad5 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -421,15 +421,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation Запуск тестов в изолированном процессе. Это снижает вероятность остановки процесса vstest.console.exe из-за ошибки в тестах, но тесты могут выполняться медленнее. - + / InIsolation Тесты выполняются в изолированном процессе. Это делает процесс vstest.console.exe менее вероятно, что остановлена на ошибки в тестах, но тесты могут работать медленнее. @@ -1587,20 +1587,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index d2ceca0e03..511c2c2327 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -420,15 +420,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation Testleri yalıtılmış bir işlemde çalıştırır. Bu işlem vstest.console.exe işleminin testlerdeki bir hata nedeniyle durdurulması olasılığını azaltır, ancak daha yavaş çalışabilir. - + / InIsolation Testleri yalıtılmış bir işlem içinde çalıştırır. Bu işlem vstest.console.exe testlerinde hata durdurulması olasılığını sağlar, ancak test çalışması yavaşlayabilir. @@ -1586,20 +1586,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index 47431f216a..845a0d6641 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -176,7 +176,7 @@ - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. @@ -734,20 +734,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index 23e03ae8d7..a6e4e3d475 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -419,15 +419,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - / InIsolation + / InIsolation 在独立进程中运行测试。虽然这可使 vstest.console.exe 进程在测试出现错误时停止的可能性较小,但是测试的 运行速度会较慢。 - + / InIsolation 在独立进程中运行测试。这使得 vstest.console.exe 进程不太可能被停止的错误在测试中,但是测试运行速度将减慢。 @@ -1585,20 +1585,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index bebc51ee26..532b9a0645 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -420,15 +420,15 @@ fuzzyMatch="15" wordcount="29" adjWordcount="24.65" curWordcount="24.65" - /InIsolation + --InIsolation|/InIsolation Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. - /InIsolation + /InIsolation 在獨立的處理序中執行測試。這樣會降低 vstest.console.exe 處理序在測試中錯誤處於停止狀態的可能性,但是測試 的執行速度可能會比較慢。 - + / InIsolation 在独立进程中运行测试。这使得 vstest.console.exe 进程不太可能被停止的错误在测试中,但是测试运行速度将减慢。 @@ -1586,20 +1586,6 @@ Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}. - - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - --InProcess|/InProcess - Runs the tests in vstest.console.exe process. - This is supported for framework ".NETFramework,Version=v4.*", Framework40 and Framework45. - - - - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - Argument {0} is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again. - - \ No newline at end of file diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 9144444bee..522047029c 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -58,7 +58,7 @@ internal class TestRequestManager : ITestRequestManager public TestRequestManager() : this(CommandLineOptions.Instance, - TestPlatformFactory.GetTestPlatform(), + TestPlatformFactory.GetTestPlatform(CommandLineOptions.Instance.InIsolation), TestLoggerManager.Instance, TestRunResultAggregator.Instance, TestPlatformEventSource.Instance) diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs index 333ea378a0..c8f5c490d4 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs @@ -26,9 +26,8 @@ public void TestInitialize() { this.mockTestHostManagerFactory = new Mock(); this.mockDiscoveryManager = new Mock(); - this.inProcessProxyDiscoveryManager = new InProcessProxyDiscoveryManager(this.mockTestHostManagerFactory.Object); - this.mockTestHostManagerFactory.Setup(o => o.GetDiscoveryManager()).Returns(this.mockDiscoveryManager.Object); + this.inProcessProxyDiscoveryManager = new InProcessProxyDiscoveryManager(this.mockTestHostManagerFactory.Object); } [TestCleanup] @@ -43,14 +42,14 @@ public void TestCleanup() public void InitializeShouldCallDiscoveryManagerInitializeWithEmptyIEnumerable() { this.inProcessProxyDiscoveryManager.Initialize(); - this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "DiscoveryManager.Initialize() should get called with empty list"); } [TestMethod] public void InitializeShouldSetIsInitializedTotrue() { this.inProcessProxyDiscoveryManager.Initialize(); - Assert.IsTrue(this.inProcessProxyDiscoveryManager.IsInitialized); + Assert.IsTrue(this.inProcessProxyDiscoveryManager.IsInitialized, "DiscoveryManager.Initialize() is not setting the value of varable IsInitialized to true"); } [TestMethod] @@ -58,7 +57,7 @@ public void InitializeShouldCallDiscoveryManagerInitializeWithEmptyIEnumerableOn { this.inProcessProxyDiscoveryManager.Initialize(); this.inProcessProxyDiscoveryManager.Initialize(); - this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "DiscoveryManager.Initialize() should get called once"); } [TestMethod] @@ -71,7 +70,7 @@ public void DiscoverTestsShouldCallInitializeIfNotAlreadyInitialized() this.inProcessProxyDiscoveryManager.DiscoverTests(null, null); - Assert.IsTrue(manualResetEvent.WaitOne(5000)); + Assert.IsTrue(manualResetEvent.WaitOne(5000), "DiscoverTests should call Initialize if not already initialized"); } [TestMethod] @@ -86,7 +85,7 @@ public void DiscoverTestsShouldNotCallInitializeIfAlreadyInitialized() this.inProcessProxyDiscoveryManager.DiscoverTests(null, null); Assert.IsTrue(manualResetEvent.WaitOne(5000)); - this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "DiscoverTests should not call Initialize if already initialized"); } [TestMethod] diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs index c93a9242f5..1623672070 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs @@ -27,9 +27,8 @@ public void TestInitialize() { this.mockTestHostManagerFactory = new Mock(); this.mockExecutionManager = new Mock(); - this.inProcessProxyExecutionManager = new InProcessProxyExecutionManager(this.mockTestHostManagerFactory.Object); - this.mockTestHostManagerFactory.Setup(o => o.GetExecutionManager()).Returns(this.mockExecutionManager.Object); + this.inProcessProxyExecutionManager = new InProcessProxyExecutionManager(this.mockTestHostManagerFactory.Object); } [TestCleanup] @@ -44,14 +43,14 @@ public void TestCleanup() public void InitializeShouldCallExecutionManagerInitializeWithEmptyIEnumerable() { this.inProcessProxyExecutionManager.Initialize(); - this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "ExecutionManager.Initialize() should get called with empty list"); } [TestMethod] public void InitializeShouldSetIsInitializedTotrue() { this.inProcessProxyExecutionManager.Initialize(); - Assert.IsTrue(this.inProcessProxyExecutionManager.IsInitialized); + Assert.IsTrue(this.inProcessProxyExecutionManager.IsInitialized, "ExecutionManager.Initialize() is not setting the value of varable IsInitialized to true"); } [TestMethod] @@ -59,7 +58,7 @@ public void InitializeShouldCallExecutionManagerInitializeWithEmptyIEnumerableOn { this.inProcessProxyExecutionManager.Initialize(); this.inProcessProxyExecutionManager.Initialize(); - this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "ExecutionManager.Initialize() should get called once"); } [TestMethod] @@ -68,7 +67,7 @@ public void StartTestRunShouldCallInitializeIfNotAlreadyInitialized() var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "StartTestRun should call Initialize if not already initialized"); } [TestMethod] @@ -78,7 +77,7 @@ public void StartTestRunShouldNotCallInitializeIfAlreadyInitialized() this.inProcessProxyExecutionManager.Initialize(); this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once); + this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "StartTestRun should not call Initialize if already initialized"); } [TestMethod] diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs index a3d82c2506..ee35fd09b8 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs @@ -29,15 +29,14 @@ public TestEngineTests() { TestPluginCacheTests.SetupMockExtensions(new[] { typeof(TestEngineTests).GetTypeInfo().Assembly.Location }, () => { }); this.mockProcessHelper = new Mock(); - this.mockProcessHelper.Setup(o => o.GetCurrentProcessFileName()).Returns("vstest.console"); - this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object); this.testableTestRuntimeProvider = new TestableRuntimeProvider(true); } - [TestCleanup] - public void TestCleanup() + [TestInitialize] + public void Init() { this.mockProcessHelper.Setup(o => o.GetCurrentProcessFileName()).Returns("vstest.console"); + this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object); } [TestMethod] @@ -50,6 +49,7 @@ public void GetDiscoveryManagerShouldReturnANonNullInstance() [TestMethod] public void GetDiscoveryManagerShouldReturnsNewInstanceOfProxyDiscoveryManagerIfTestHostIsShared() { + this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, null); var discoveryManager = this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig); @@ -60,6 +60,7 @@ public void GetDiscoveryManagerShouldReturnsNewInstanceOfProxyDiscoveryManagerIf [TestMethod] public void GetDiscoveryManagerShouldReturnsParallelDiscoveryManagerIfTestHostIsNotShared() { + this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, null); this.testableTestRuntimeProvider = new TestableRuntimeProvider(false); @@ -84,9 +85,9 @@ public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfD string settingXml = @" - true + x86 true - true + false .NETFramework, Version=v4.5 "; @@ -104,7 +105,7 @@ public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfD string settingXml = @" - true + x86 false true .NETFramework, Version=v4.5 @@ -124,7 +125,7 @@ public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIf string settingXml = @" - true + x86 false false .NETCoreApp, Version=v1.1 @@ -144,7 +145,27 @@ public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIf string settingXml = @" - true + x86 + false + false + .NETStandard, Version=v1.4 + + "; + + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + + var discoveryManager = this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } + + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIfTargetPlatformIsX64() + { + string settingXml = + @" + + x64 false false .NETStandard, Version=v1.4 @@ -164,7 +185,7 @@ public void GetDiscoveryManagerShouldReturnsInProcessProxyDiscoveryManager() string settingXml = @" - true + x86 false false .NETFramework, Version=v4.5 @@ -198,7 +219,8 @@ public void GetExecutionManagerShouldReturnNewInstance() [TestMethod] public void GetExecutionManagerShouldReturnDefaultExecutionManagerIfParallelDisabled() { - string settingXml = @""; + this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); + string settingXml = @""; var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100, false, settingXml); Assert.IsNotNull(this.testEngine.GetExecutionManager(this.testableTestRuntimeProvider, testRunCriteria, this.protocolConfig)); @@ -208,6 +230,7 @@ public void GetExecutionManagerShouldReturnDefaultExecutionManagerIfParallelDisa [TestMethod] public void GetExecutionManagerWithSingleSourceShouldReturnDefaultExecutionManagerEvenIfParallelEnabled() { + this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); string settingXml = @"2"; var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100, false, settingXml); @@ -228,6 +251,7 @@ public void GetExecutionManagerShouldReturnParallelExecutionManagerIfParallelEna [TestMethod] public void GetExecutionManagerShouldReturnParallelExecutionManagerIfHostIsNotShared() { + this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); this.testableTestRuntimeProvider = new TestableRuntimeProvider(false); var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, null); @@ -246,13 +270,33 @@ public void GetExcecutionManagerShouldReturnExectuionManagerWithDataCollectionIf Assert.IsInstanceOfType(result, typeof(ProxyExecutionManagerWithDataCollection)); } + [TestMethod] + public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfInIsolationIsTrue() + { + this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); + string settingXml = + @" + + false + false + .NETFramework, Version=v4.5 + + "; + + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + + var executionManager = this.testEngine.GetExecutionManager(this.testableTestRuntimeProvider, testRunCriteria, this.protocolConfig); + + Assert.IsNotNull(executionManager); + Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); + } + [TestMethod] public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfParallelEnabled() { string settingXml = @" - true false false .NETFramework, Version=v4.5 @@ -274,7 +318,6 @@ public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfDa string settingXml = @" - true false false .NETFramework, Version=v4.5 @@ -296,13 +339,13 @@ public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfDa Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); } + [TestMethod] public void GetExecutionManagerShouldReturnInProcessProxyexecutionManager() { string settingXml = @" - true false false .NETFramework, Version=v4.5 diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs index e2bf3791a7..f6664b565a 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs @@ -10,8 +10,8 @@ namespace TestPlatform.CrossPlatEngine.UnitTests public class TestableTestEngine : TestEngine { - public TestableTestEngine(IProcessHelper processHelper) - : base(TestRuntimeProviderManager.Instance, processHelper) + public TestableTestEngine(IProcessHelper processHelper, bool isInIsolation = false) + : base(TestRuntimeProviderManager.Instance, processHelper, isInIsolation) { } } diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs index 0e3ed7ab67..ba6b2430f6 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs @@ -32,7 +32,6 @@ public void RunConfigurationDefaultValuesMustBeUsedOnCreation() Assert.AreEqual(Constants.DefaultCpuCount, runConfiguration.MaxCpuCount); Assert.AreEqual(false, runConfiguration.DisableAppDomain); Assert.AreEqual(false, runConfiguration.DisableParallelization); - Assert.AreEqual(false, runConfiguration.InProcess); Assert.AreEqual(false, runConfiguration.DesignMode); Assert.AreEqual(runConfiguration.DesignMode, runConfiguration.ShouldCollectSourceInformation); Assert.AreEqual(Constants.DefaultExecutionThreadApartmentState, runConfiguration.ExecutionThreadApartmentState); @@ -70,7 +69,6 @@ public void RunConfigurationReadsValuesCorrectlyFromXml() true true true - true 2 5 10000 @@ -105,7 +103,6 @@ public void RunConfigurationReadsValuesCorrectlyFromXml() Assert.AreEqual(10000, runConfiguration.TestSessionTimeout); Assert.AreEqual(true, runConfiguration.DisableAppDomain); Assert.AreEqual(true, runConfiguration.DisableParallelization); - Assert.AreEqual(true, runConfiguration.InProcess); Assert.AreEqual(true, runConfiguration.DesignMode); Assert.AreEqual(false, runConfiguration.ShouldCollectSourceInformation); Assert.AreEqual(PlatformApartmentState.STA, runConfiguration.ExecutionThreadApartmentState); diff --git a/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs index ea312cb0ee..ea24295e97 100644 --- a/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs @@ -3,46 +3,76 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors { - using System.Diagnostics; - using System.IO; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - [TestClass] public class InIsolationArgumentProcessorTests { - private readonly InIsolationArgumentProcessor isolationProcessor; + private InIsolationArgumentExecutor executor; + + [TestInitialize] + public void Init() + { + this.executor = new InIsolationArgumentExecutor(CommandLineOptions.Instance); + } + + [TestCleanup] + public void TestCleanup() + { + CommandLineOptions.Instance.Reset(); + } + + [TestMethod] + public void GetMetadataShouldReturnInProcessArgumentProcessorCapabilities() + { + var processor = new InIsolationArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is InIsolationArgumentProcessorCapabilities); + } - public InIsolationArgumentProcessorTests() + [TestMethod] + public void GetExecuterShouldReturnInProcessArgumentExecutor() { - this.isolationProcessor = new InIsolationArgumentProcessor(); + var processor = new InIsolationArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is InIsolationArgumentExecutor); } [TestMethod] public void InIsolationArgumentProcessorMetadataShouldProvideAppropriateCapabilities() { - Assert.IsFalse(this.isolationProcessor.Metadata.Value.AllowMultiple); - Assert.IsFalse(this.isolationProcessor.Metadata.Value.AlwaysExecute); - Assert.IsFalse(this.isolationProcessor.Metadata.Value.IsAction); - Assert.IsFalse(this.isolationProcessor.Metadata.Value.IsSpecialCommand); - Assert.AreEqual(InIsolationArgumentProcessor.CommandName, this.isolationProcessor.Metadata.Value.CommandName); - Assert.AreEqual(null, this.isolationProcessor.Metadata.Value.ShortCommandName); - Assert.AreEqual(ArgumentProcessorPriority.Normal, this.isolationProcessor.Metadata.Value.Priority); - Assert.AreEqual(HelpContentPriority.InIsolationArgumentProcessorHelpPriority, this.isolationProcessor.Metadata.Value.HelpPriority); + var isolationProcessor = new InIsolationArgumentProcessor(); + Assert.IsFalse(isolationProcessor.Metadata.Value.AllowMultiple); + Assert.IsFalse(isolationProcessor.Metadata.Value.AlwaysExecute); + Assert.IsFalse(isolationProcessor.Metadata.Value.IsAction); + Assert.IsFalse(isolationProcessor.Metadata.Value.IsSpecialCommand); + Assert.AreEqual(InIsolationArgumentProcessor.CommandName, isolationProcessor.Metadata.Value.CommandName); + Assert.AreEqual(null, isolationProcessor.Metadata.Value.ShortCommandName); + Assert.AreEqual(ArgumentProcessorPriority.Normal, isolationProcessor.Metadata.Value.Priority); + Assert.AreEqual(HelpContentPriority.InIsolationArgumentProcessorHelpPriority, isolationProcessor.Metadata.Value.HelpPriority); + Assert.AreEqual("--InIsolation|/InIsolation\n Runs the tests in an isolated process. This makes vstest.console.exe \n process less likely to be stopped on an error in the tests, but tests \n may run slower.", isolationProcessor.Metadata.Value.HelpContentResourceName); } [TestMethod] public void InIsolationArgumentProcessorExecutorShouldThrowIfArgumentIsProvided() { - Assert.ThrowsException(() => this.isolationProcessor.Executor.Value.Initialize("foo")); + // InProcess should not have any values or arguments + ExceptionUtilities.ThrowsException( + () => this.executor.Initialize("true"), + "Argument " + "true" + " is not expected in the 'InIsolation' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InIsolation) and try again."); + } + + [TestMethod] + public void InitializeShouldSetInIsolationValue() + { + this.executor.Initialize(null); + Assert.IsTrue(CommandLineOptions.Instance.InIsolation, "InProcess option must be set to true."); + } + + [TestMethod] + public void ExecuteShouldReturnSuccess() + { + Assert.AreEqual(ArgumentProcessorResult.Success, this.executor.Execute()); } } diff --git a/test/vstest.console.UnitTests/Processors/InProcessArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/InProcessArgumentProcessorTests.cs deleted file mode 100644 index 0ae25b68b5..0000000000 --- a/test/vstest.console.UnitTests/Processors/InProcessArgumentProcessorTests.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors -{ - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using TestPlatform.CommandLine.Processors; - using vstest.console.UnitTests.Processors; - - [TestClass] - public class InProcessArgumentProcessorTests - { - private InProcessArgumentExecutor executor; - private TestableRunSettingsProvider runSettingsProvider; - - [TestInitialize] - public void Init() - { - this.runSettingsProvider = new TestableRunSettingsProvider(); - this.executor = new InProcessArgumentExecutor(CommandLineOptions.Instance, this.runSettingsProvider); - } - [TestCleanup] - public void TestCleanup() - { - CommandLineOptions.Instance.Reset(); - } - - [TestMethod] - public void GetMetadataShouldReturnInProcessArgumentProcessorCapabilities() - { - var processor = new InProcessArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is InProcessArgumentProcessorCapabilities); - } - - [TestMethod] - public void GetExecuterShouldReturnInProcessArgumentExecutor() - { - var processor = new InProcessArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is InProcessArgumentExecutor); - } - - #region InProcessArgumentProcessorCapabilities tests - - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new InProcessArgumentProcessorCapabilities(); - Assert.AreEqual("/InProcess", capabilities.CommandName); - Assert.AreEqual("--InProcess|/InProcess\n Runs the tests in vstest.console.exe process.\n This is supported for framework \".NETFramework,Version=v4.*\", Framework40 and Framework45.", capabilities.HelpContentResourceName); - - Assert.AreEqual(HelpContentPriority.InProcessArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.AreEqual(false, capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); - - Assert.AreEqual(false, capabilities.AllowMultiple); - Assert.AreEqual(false, capabilities.AlwaysExecute); - Assert.AreEqual(false, capabilities.IsSpecialCommand); - } - - #endregion - - #region InProcessArgumentExecutor Initialize tests - - [TestMethod] - public void InitializeShouldThrowIfArgumentIsNonNull() - { - // InProcess should not have any values or arguments - ExceptionUtilities.ThrowsException( - () => this.executor.Initialize("true"), - "Argument " + "true" + " is not expected in the 'InProcess' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InProcess) and try again."); - } - - [TestMethod] - public void InitializeShouldSetInProcessValue() - { - this.executor.Initialize(null); - Assert.IsTrue(CommandLineOptions.Instance.InProcess, "InProcess option must be set to true."); - Assert.AreEqual("true", this.runSettingsProvider.QueryRunSettingsNode(InProcessArgumentExecutor.RunSettingsPath)); - } - - #endregion - - #region InProcessArgumentExecutor Execute tests - - [TestMethod] - public void ExecuteShouldReturnSuccess() - { - Assert.AreEqual(ArgumentProcessorResult.Success, this.executor.Execute()); - } - - #endregion - } -} From 172f9d065c5b4a9b5f55acd3e1bd59aaa080d562 Mon Sep 17 00:00:00 2001 From: faahmad Date: Mon, 28 Aug 2017 14:11:23 +0530 Subject: [PATCH 6/8] Disable inprocess for inProcDataCollector. --- .../TestEngine.cs | 3 +- .../TestEngineTests.cs | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs index a2d0bc1f5b..475326acd0 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs @@ -96,8 +96,9 @@ public IProxyExecutionManager GetExecutionManager(ITestRuntimeProvider testHostM var parallelLevel = this.VerifyParallelSettingAndCalculateParallelLevel(distinctSources, testRunCriteria.TestRunSettings); var isDataCollectorEnabled = XmlRunSettingsUtilities.IsDataCollectionEnabled(testRunCriteria.TestRunSettings); + var isInProcDataCollectorEnabled = XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(testRunCriteria.TestRunSettings); - if (this.ShouldRunInNoIsolation(testRunCriteria.TestRunSettings, parallelLevel > 1, isDataCollectorEnabled)) + if (this.ShouldRunInNoIsolation(testRunCriteria.TestRunSettings, parallelLevel > 1, isDataCollectorEnabled || isInProcDataCollectorEnabled)) { return new InProcessProxyExecutionManager(); } diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs index ee35fd09b8..9f2523b2c0 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs @@ -339,6 +339,36 @@ public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfDa Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); } + [TestMethod] + public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfInProcDataCollectorIsEnabled() + { + string settingXml = + @" + + false + false + .NETFramework, Version=v4.5 + 1 + + + + + + 4312 + + + + + "; + + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + + var executionManager = this.testEngine.GetExecutionManager(this.testableTestRuntimeProvider, testRunCriteria, this.protocolConfig); + + Assert.IsNotNull(executionManager); + Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); + } + [TestMethod] public void GetExecutionManagerShouldReturnInProcessProxyexecutionManager() From 39c40c20dca9f7186dc36df84028b868a08b97dd Mon Sep 17 00:00:00 2001 From: faahmad Date: Tue, 29 Aug 2017 00:04:38 +0530 Subject: [PATCH 7/8] Addressed Arun comment --- .../TestPlatform.cs | 2 +- .../TestPlatformFactory.cs | 4 +- .../Client/InProcessProxyDiscoveryManager.cs | 36 ++++++---- .../Client/InProcessProxyexecutionManager.cs | 46 ++++++++----- .../TestEngine.cs | 16 ++--- .../RunSettings/RunConfiguration.cs | 39 +++++++++++ .../InIsolationArgumentProcessor.cs | 22 +++++-- .../TestPlatformHelpers/TestRequestManager.cs | 2 +- .../ExecutionTests.cs | 2 + .../PlatformTests.cs | 2 + .../RunsettingsTests.cs | 20 +++--- .../InProcessProxyDiscoveryManagerTests.cs | 66 +++++++++---------- .../InProcessProxyexecutionManagerTests.cs | 43 +++++------- .../TestEngineTests.cs | 41 ++++++++---- .../TestableTestEngine.cs | 4 +- .../RunSettings/RunConfigurationTests.cs | 3 + .../InIsolationArgumentProcessorTests.cs | 9 ++- 17 files changed, 226 insertions(+), 131 deletions(-) diff --git a/src/Microsoft.TestPlatform.Client/TestPlatform.cs b/src/Microsoft.TestPlatform.Client/TestPlatform.cs index df68fc92cb..d70dc1946f 100644 --- a/src/Microsoft.TestPlatform.Client/TestPlatform.cs +++ b/src/Microsoft.TestPlatform.Client/TestPlatform.cs @@ -47,7 +47,7 @@ static TestPlatform() /// Initializes a new instance of the class. /// /// inIsolation command line arg value - public TestPlatform(bool isInIsolation = false) : this(new TestEngine(isInIsolation), new FileHelper(), TestRuntimeProviderManager.Instance) + public TestPlatform() : this(new TestEngine(), new FileHelper(), TestRuntimeProviderManager.Instance) { } diff --git a/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs b/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs index 4f1bf0e04f..44ffa5e33f 100644 --- a/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs +++ b/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs @@ -16,9 +16,9 @@ public class TestPlatformFactory /// Gets an instance of the test platform. /// /// The instance. - public static ITestPlatform GetTestPlatform(bool isInIsolation) + public static ITestPlatform GetTestPlatform() { - return testPlatform ?? (testPlatform = new TestPlatform(isInIsolation)); + return testPlatform ?? (testPlatform = new TestPlatform()); } } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs index bbfba3f2ec..c3e8b2b2e6 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs @@ -7,22 +7,25 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; + using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; internal class InProcessProxyDiscoveryManager : IProxyDiscoveryManager { private ITestHostManagerFactory testHostManagerFactory; - IDiscoveryManager discoveryManager; + private IDiscoveryManager discoveryManager; + private ITestRuntimeProvider testHostManager; public bool IsInitialized { get; private set; } = false; /// /// Initializes a new instance of the class. /// - public InProcessProxyDiscoveryManager() : this(new TestHostManagerFactory()) + public InProcessProxyDiscoveryManager(ITestRuntimeProvider testHostManager) : this(testHostManager, new TestHostManagerFactory()) { } @@ -30,8 +33,9 @@ public InProcessProxyDiscoveryManager() : this(new TestHostManagerFactory()) /// Initializes a new instance of the class. /// /// Manager factory - internal InProcessProxyDiscoveryManager(ITestHostManagerFactory testHostManagerFactory) + internal InProcessProxyDiscoveryManager(ITestRuntimeProvider testHostManager, ITestHostManagerFactory testHostManagerFactory) { + this.testHostManager = testHostManager; this.testHostManagerFactory = testHostManagerFactory; this.discoveryManager = this.testHostManagerFactory.GetDiscoveryManager(); } @@ -41,13 +45,6 @@ internal InProcessProxyDiscoveryManager(ITestHostManagerFactory testHostManagerF /// public void Initialize() { - if(!this.IsInitialized) - { - // We don't need to pass list of extension as we are running inside vstest.console and - // it will use TestPluginCache of vstest.console - this.discoveryManager.Initialize(Enumerable.Empty()); - this.IsInitialized = true; - } } /// @@ -61,8 +58,8 @@ public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEve { try { - // Initialize extension before discovery if it’s not initialized - this.Initialize(); + // Initialize extension before discovery + this.InitializeExtensions(discoveryCriteria.Sources); this.discoveryManager.DiscoverTests(discoveryCriteria, eventHandler); } catch (Exception exception) @@ -71,7 +68,7 @@ public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEve // Send a discovery complete to caller. eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.ToString()); - eventHandler.HandleDiscoveryComplete(-1, new List(), true); + eventHandler.HandleDiscoveryComplete(-1, Enumerable.Empty(), true); } } ); @@ -92,5 +89,18 @@ public void Abort() { Task.Run(() => this.testHostManagerFactory.GetDiscoveryManager().Abort()); } + + private void InitializeExtensions(IEnumerable sources) + { + var extensionsFromSource = this.testHostManager.GetTestPlatformExtensions(sources, Enumerable.Empty()); + if (extensionsFromSource.Any()) + { + TestPluginCache.Instance.UpdateExtensions(extensionsFromSource, false); + } + + // We don't need to pass list of extension as we are running inside vstest.console and + // it will use TestPluginCache of vstest.console + discoveryManager.Initialize(Enumerable.Empty()); + } } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs index 991198cc61..6f7117c290 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs @@ -4,26 +4,30 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client { using System; + using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; + using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; internal class InProcessProxyExecutionManager : IProxyExecutionManager { private ITestHostManagerFactory testHostManagerFactory; - IExecutionManager executionManager; + private IExecutionManager executionManager; + private ITestRuntimeProvider testHostManager; public bool IsInitialized { get; private set; } = false; /// /// Initializes a new instance of the class. /// - public InProcessProxyExecutionManager() : this(new TestHostManagerFactory()) + public InProcessProxyExecutionManager(ITestRuntimeProvider testHostManager) : this(testHostManager, new TestHostManagerFactory()) { } @@ -33,8 +37,9 @@ public InProcessProxyExecutionManager() : this(new TestHostManagerFactory()) /// /// Manager factory /// - internal InProcessProxyExecutionManager(ITestHostManagerFactory testHostManagerFactory) + internal InProcessProxyExecutionManager(ITestRuntimeProvider testHostManager, ITestHostManagerFactory testHostManagerFactory) { + this.testHostManager = testHostManager; this.testHostManagerFactory = testHostManagerFactory; this.executionManager = this.testHostManagerFactory.GetExecutionManager(); } @@ -44,13 +49,6 @@ internal InProcessProxyExecutionManager(ITestHostManagerFactory testHostManagerF /// public void Initialize() { - if (!this.IsInitialized) - { - // We don't need to pass list of extension as we are running inside vstest.console and - // it will use TestPluginCache of vstest.console - executionManager.Initialize(Enumerable.Empty()); - this.IsInitialized = true; - } } /// @@ -58,9 +56,6 @@ public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler e { try { - // Initialize extension before execution if not already initialized - this.Initialize(); - var executionContext = new TestExecutionContext( testRunCriteria.FrequencyOfRunStatsChangeEvent, testRunCriteria.RunStatsChangeEventTimeout, @@ -75,12 +70,19 @@ public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler e if (testRunCriteria.HasSpecificSources) { - // [TODO]: we need to revisit to second-last argument if we will enable datacollector. + // Initialize extension before execution + this.InitializeExtensions(testRunCriteria.Sources); + Task.Run(() => executionManager.StartTestRun(testRunCriteria.AdapterSourceMap, testRunCriteria.TestRunSettings, executionContext, null, eventHandler)); } else { - // [TODO]: we need to revisit to second-last argument if we will enable datacollector. + // If the test execution is with a test filter, group them by sources + var testSources = testRunCriteria.Tests.GroupBy(tc => tc.Source).Select(g => g.Key); + + // Initialize extension before execution + this.InitializeExtensions(testSources); + Task.Run(() => executionManager.StartTestRun(testRunCriteria.Tests, testRunCriteria.TestRunSettings, executionContext, null, eventHandler)); } } @@ -122,5 +124,19 @@ public void Cancel() public void Close() { } + + + private void InitializeExtensions(IEnumerable sources) + { + var extensionsFromSource = this.testHostManager.GetTestPlatformExtensions(sources, Enumerable.Empty()); + if (extensionsFromSource.Any()) + { + TestPluginCache.Instance.UpdateExtensions(extensionsFromSource, false); + } + + // We don't need to pass list of extension as we are running inside vstest.console and + // it will use TestPluginCache of vstest.console + executionManager.Initialize(Enumerable.Empty()); + } } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs index 475326acd0..0159d1e4d5 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs @@ -31,19 +31,17 @@ public class TestEngine : ITestEngine private readonly TestRuntimeProviderManager testHostProviderManager; private ITestExtensionManager testExtensionManager; private IProcessHelper processHelper; - private bool isInIsolation = false; #endregion - public TestEngine(bool isInIsolation = false) : this(TestRuntimeProviderManager.Instance, new ProcessHelper(), isInIsolation) + public TestEngine() : this(TestRuntimeProviderManager.Instance, new ProcessHelper()) { } - protected TestEngine(TestRuntimeProviderManager testHostProviderManager, IProcessHelper processHelper, bool isInIsolation) + protected TestEngine(TestRuntimeProviderManager testHostProviderManager, IProcessHelper processHelper) { this.testHostProviderManager = testHostProviderManager; this.processHelper = processHelper; - this.isInIsolation = isInIsolation; } #region ITestEngine implementation @@ -67,7 +65,7 @@ public IProxyDiscoveryManager GetDiscoveryManager(ITestRuntimeProvider testHostM if (this.ShouldRunInNoIsolation(discoveryCriteria.RunSettings, parallelLevel > 1, false)) { - return new InProcessProxyDiscoveryManager(); + return new InProcessProxyDiscoveryManager(testHostManager); } Func proxyDiscoveryManagerCreator = delegate @@ -100,7 +98,7 @@ public IProxyExecutionManager GetExecutionManager(ITestRuntimeProvider testHostM if (this.ShouldRunInNoIsolation(testRunCriteria.TestRunSettings, parallelLevel > 1, isDataCollectorEnabled || isInProcDataCollectorEnabled)) { - return new InProcessProxyExecutionManager(); + return new InProcessProxyExecutionManager(testHostManager); } // SetupChannel ProxyExecutionManager with data collection if data collectors are specififed in run settings. @@ -213,7 +211,9 @@ private int VerifyParallelSettingAndCalculateParallelLevel(int sourceCount, stri private bool ShouldRunInNoIsolation(string runsettings, bool isParallelEnabled, bool isDataCollectorEnabled) { - if(this.isInIsolation == true) + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings); + + if (runConfiguration.InIsolation) { if (EqtTrace.IsInfoEnabled) { @@ -231,8 +231,6 @@ private bool ShouldRunInNoIsolation(string runsettings, bool isParallelEnabled, return false; } - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings); - // Return true if // 1) Not running in parallel // 2) Data collector is not enabled diff --git a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs index 239813e352..70d0892e61 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs @@ -69,6 +69,11 @@ public class RunConfiguration : TestRunSettings /// private bool designMode; + /// + /// Specify to run tests in isolation + /// + private bool inIsolation; + /// /// False indicates that the test adapter should not collect source information for discovered tests /// @@ -97,6 +102,7 @@ public RunConfiguration() : base(Constants.RunConfigurationSettingsName) this.disableAppDomain = false; this.disableParallelization = false; this.designMode = false; + this.inIsolation = false; this.shouldCollectSourceInformation = false; this.ExecutionThreadApartmentState = Constants.DefaultExecutionThreadApartmentState; } @@ -196,6 +202,22 @@ public bool DesignMode } } + /// + /// Gets or sets a value indicating whether to run tests in isolation or not. + /// + public bool InIsolation + { + get + { + return this.inIsolation; + } + + set + { + this.inIsolation = value; + } + } + /// /// Gets a value indicating whether test adapter needs to collect source information for discovered tests /// @@ -456,6 +478,10 @@ public override XmlElement ToXml() designMode.InnerXml = this.DesignMode.ToString(); root.AppendChild(designMode); + XmlElement inIsolation = doc.CreateElement("InIsolation"); + inIsolation.InnerXml = this.InIsolation.ToString(); + root.AppendChild(inIsolation); + XmlElement collectSourceInformation = doc.CreateElement("CollectSourceInformation"); collectSourceInformation.InnerXml = this.ShouldCollectSourceInformation.ToString(); root.AppendChild(collectSourceInformation); @@ -608,6 +634,19 @@ public static RunConfiguration FromXml(XmlReader reader) runConfiguration.DesignMode = designMode; break; + case "InIsolation": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + + string inIsolationValueString = reader.ReadElementContentAsString(); + bool inIsolation; + if (!bool.TryParse(inIsolationValueString, out inIsolation)) + { + throw new SettingsException(String.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, inIsolationValueString, elementName)); + } + runConfiguration.InIsolation = inIsolation; + break; + case "DisableAppDomain": XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); diff --git a/src/vstest.console/Processors/InIsolationArgumentProcessor.cs b/src/vstest.console/Processors/InIsolationArgumentProcessor.cs index a1d9a9c01c..8779531d81 100644 --- a/src/vstest.console/Processors/InIsolationArgumentProcessor.cs +++ b/src/vstest.console/Processors/InIsolationArgumentProcessor.cs @@ -5,7 +5,9 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors using System; using System.Diagnostics.Contracts; using System.Globalization; - using Microsoft.VisualStudio.TestPlatform.Utilities; + using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; + using Microsoft.VisualStudio.TestPlatform.Common; + using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; /// @@ -52,7 +54,7 @@ public Lazy Executor this.executor = new Lazy( () => - new InIsolationArgumentExecutor(CommandLineOptions.Instance)); + new InIsolationArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); } return this.executor; @@ -73,7 +75,7 @@ internal class InIsolationArgumentProcessorCapabilities : BaseArgumentProcessorC public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; public override string HelpContentResourceName => CommandLineResources.InIsolationHelp; @@ -83,11 +85,21 @@ internal class InIsolationArgumentProcessorCapabilities : BaseArgumentProcessorC internal class InIsolationArgumentExecutor : IArgumentExecutor { private CommandLineOptions commandLineOptions; + private IRunSettingsProvider runSettingsManager; + + public const string RunSettingsPath = "RunConfiguration.InIsolation"; + #region Constructors - public InIsolationArgumentExecutor(CommandLineOptions options) + /// + /// Constructor + /// + /// Commandline options + /// the runsettings manager + public InIsolationArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) { Contract.Requires(options != null); this.commandLineOptions = options; + this.runSettingsManager = runSettingsManager; } #endregion @@ -99,6 +111,7 @@ public InIsolationArgumentExecutor(CommandLineOptions options) /// Argument that was provided with the command. public void Initialize(string argument) { + // InIsolation does not require any argument, throws exception if argument specified if (!string.IsNullOrWhiteSpace(argument)) { throw new CommandLineException( @@ -106,6 +119,7 @@ public void Initialize(string argument) } this.commandLineOptions.InIsolation = true; + this.runSettingsManager.UpdateRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath, "true"); } /// diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 522047029c..9144444bee 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -58,7 +58,7 @@ internal class TestRequestManager : ITestRequestManager public TestRequestManager() : this(CommandLineOptions.Instance, - TestPlatformFactory.GetTestPlatform(CommandLineOptions.Instance.InIsolation), + TestPlatformFactory.GetTestPlatform(), TestLoggerManager.Instance, TestRunResultAggregator.Instance, TestPlatformEventSource.Instance) diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs index 3c7edd9d27..9a0fbc75c0 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs @@ -146,6 +146,7 @@ public void StackOverflowExceptionShouldBeLoggedToConsoleAndDiagLogFile(string r var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue); arguments = string.Concat(arguments, " /testcasefilter:ExitWithStackoverFlow"); arguments = string.Concat(arguments, $" /diag:{diagLogFilePath}"); + arguments = string.Concat(arguments, $" /InIsolation"); this.InvokeVsTest(arguments); var errorMessage = string.Empty; @@ -179,6 +180,7 @@ public void UnhandleExceptionExceptionShouldBeLoggedToDiagLogFile(string runnerF var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue); arguments = string.Concat(arguments, " /testcasefilter:ExitwithUnhandleException"); arguments = string.Concat(arguments, $" /diag:{diagLogFilePath}"); + arguments = string.Concat(arguments, $" /InIsolation"); this.InvokeVsTest(arguments); var errorFirstLine = "Test host standard error line: Unhandled Exception: System.InvalidOperationException: Operation is not valid due to the current state of the object."; diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/PlatformTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/PlatformTests.cs index 80e135ac24..7f74424c25 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/PlatformTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/PlatformTests.cs @@ -80,6 +80,8 @@ private void RunTestExecutionWithPlatform(string platformArg, string testhostPro this.FrameworkArgValue); arguments = string.Concat(arguments, platformArg); + arguments = arguments + " /InIsolation"; + var cts = new CancellationTokenSource(); var numOfProcessCreatedTask = NumberOfProcessLaunchedUtility.NumberOfProcessCreated( cts, diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs index 25d1863e64..064a30fa69 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs @@ -38,7 +38,7 @@ public void CommandLineRunSettingsShouldWinAmongAllOptions(string runnerFramewor { "TestAdaptersPaths", this.GetTestAdapterPath() } }; // passing different platform - var additionalArgs = "/Platform:x64"; + var additionalArgs = "/Platform:x64 /InIsolation"; var runSettingsArgs = String.Join( " ", @@ -68,7 +68,7 @@ public void CLIRunsettingsShouldWinBetweenCLISwitchesAndCLIRunsettings(string ru var expectedNumOfProcessCreated = GetExpectedNumOfProcessCreatedForWithoutParallel(); // Pass parallel - var additionalArgs = "/Parallel"; + var additionalArgs = "/Parallel /InIsolation"; // Pass non parallel var runSettingsArgs = String.Join( @@ -109,7 +109,7 @@ public void CommandLineSwitchesShouldWinBetweenSettingsFileAndCommandLineSwitche { "TargetFrameworkVersion", this.GetTargetFramworkForRunsettings() }, { "TestAdaptersPaths", this.GetTestAdapterPath() } }; - var additionalArgs = "/Platform:x86"; + var additionalArgs = "/Platform:x86 /InIsolation"; this.RunTestWithRunSettings(runConfigurationDictionary, null, additionalArgs, testhostProcessName, expectedNumOfProcessCreated); } @@ -134,7 +134,7 @@ public void RunSettingsWithoutParallelAndPlatformX86(string runnerFramework, str { "TargetFrameworkVersion", this.GetTargetFramworkForRunsettings() }, { "TestAdaptersPaths", this.GetTestAdapterPath() } }; - this.RunTestWithRunSettings(runConfigurationDictionary, null, null, testhostProcessName, expectedNumOfProcessCreated); + this.RunTestWithRunSettings(runConfigurationDictionary, null, "/InIsolation", testhostProcessName, expectedNumOfProcessCreated); } [CustomDataTestMethod] @@ -158,7 +158,7 @@ public void RunSettingsParamsAsArguments(string runnerFramework, string targetFr string.Concat("RunConfiguration.TestAdaptersPaths=" , this.GetTestAdapterPath()) }); - this.RunTestWithRunSettings(null, runSettingsArgs, null, testhostProcessName, expectedNumOfProcessCreated); + this.RunTestWithRunSettings(null, runSettingsArgs, "/InIsolation", testhostProcessName, expectedNumOfProcessCreated); } [CustomDataTestMethod] @@ -189,7 +189,7 @@ public void RunSettingsAndRunSettingsParamsAsArguments(string runnerFramework, s string.Concat("RunConfiguration.TestAdaptersPaths=" , this.GetTestAdapterPath()) }); - this.RunTestWithRunSettings(runConfigurationDictionary, runSettingsArgs, null, testhostProcessName, expectedNumOfProcessCreated); + this.RunTestWithRunSettings(runConfigurationDictionary, runSettingsArgs, "/InIsolation", testhostProcessName, expectedNumOfProcessCreated); } // Randomly failing with error "The active test run was aborted. Reason: Destination array was not long enough. @@ -266,14 +266,14 @@ private void RunTestWithRunSettings(Dictionary runConfigurationD var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), runsettingsPath, this.FrameworkArgValue); - if (!string.IsNullOrWhiteSpace(runSettingsArgs)) + if (!string.IsNullOrWhiteSpace(additionalArgs)) { - arguments = string.Concat(arguments, " -- ", runSettingsArgs); + arguments = string.Concat(arguments, " ", additionalArgs); } - if (!string.IsNullOrWhiteSpace(additionalArgs)) + if (!string.IsNullOrWhiteSpace(runSettingsArgs)) { - arguments = string.Concat(arguments, " ", additionalArgs); + arguments = string.Concat(arguments, " -- ", runSettingsArgs); } var cts = new CancellationTokenSource(); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs index c8f5c490d4..a2382a4dab 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs @@ -7,10 +7,12 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Client using System.Collections.Generic; using System.Linq; using System.Threading; + using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; @@ -20,14 +22,16 @@ public class InProcessProxyDiscoveryManagerTests private Mock mockTestHostManagerFactory; private InProcessProxyDiscoveryManager inProcessProxyDiscoveryManager; private Mock mockDiscoveryManager; + private Mock mockTestHostManager; [TestInitialize] public void TestInitialize() { this.mockTestHostManagerFactory = new Mock(); this.mockDiscoveryManager = new Mock(); + this.mockTestHostManager = new Mock(); this.mockTestHostManagerFactory.Setup(o => o.GetDiscoveryManager()).Returns(this.mockDiscoveryManager.Object); - this.inProcessProxyDiscoveryManager = new InProcessProxyDiscoveryManager(this.mockTestHostManagerFactory.Object); + this.inProcessProxyDiscoveryManager = new InProcessProxyDiscoveryManager(this.mockTestHostManager.Object, this.mockTestHostManagerFactory.Object); } [TestCleanup] @@ -36,56 +40,48 @@ public void TestCleanup() this.mockDiscoveryManager = null; this.mockTestHostManagerFactory = null; this.inProcessProxyDiscoveryManager = null; + this.mockTestHostManager = null; } - [TestMethod] - public void InitializeShouldCallDiscoveryManagerInitializeWithEmptyIEnumerable() - { - this.inProcessProxyDiscoveryManager.Initialize(); - this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "DiscoveryManager.Initialize() should get called with empty list"); - } [TestMethod] - public void InitializeShouldSetIsInitializedTotrue() + public void DiscoverTestsShouldCallInitialize() { - this.inProcessProxyDiscoveryManager.Initialize(); - Assert.IsTrue(this.inProcessProxyDiscoveryManager.IsInitialized, "DiscoveryManager.Initialize() is not setting the value of varable IsInitialized to true"); - } - - [TestMethod] - public void InitializeShouldCallDiscoveryManagerInitializeWithEmptyIEnumerableOnlyOnce() - { - this.inProcessProxyDiscoveryManager.Initialize(); - this.inProcessProxyDiscoveryManager.Initialize(); - this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "DiscoveryManager.Initialize() should get called once"); - } - - [TestMethod] - public void DiscoverTestsShouldCallInitializeIfNotAlreadyInitialized() - { - var manualResetEvent = new ManualResetEvent(true); + var manualResetEvent = new ManualResetEvent(false); this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty())).Callback( () => manualResetEvent.Set()); - this.inProcessProxyDiscoveryManager.DiscoverTests(null, null); + var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); + this.inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, null); - Assert.IsTrue(manualResetEvent.WaitOne(5000), "DiscoverTests should call Initialize if not already initialized"); + Assert.IsTrue(manualResetEvent.WaitOne(5000), "DiscoverTests should call Initialize"); } [TestMethod] - public void DiscoverTestsShouldNotCallInitializeIfAlreadyInitialized() + public void DiscoverTestsShouldUpdateTestPlauginCacheWithExtensionsReturnByTestHost() { - var manualResetEvent = new ManualResetEvent(true); + var manualResetEvent = new ManualResetEvent(false); this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty())).Callback( () => manualResetEvent.Set()); - this.inProcessProxyDiscoveryManager.Initialize(); - this.inProcessProxyDiscoveryManager.DiscoverTests(null, null); + this.mockTestHostManager.Setup(o => o.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List { "C:\\DiscoveryDummy.dll" }); + + List expectedResult = new List(); + if (TestPluginCache.Instance.PathToExtensions != null) + { + expectedResult.AddRange(TestPluginCache.Instance.PathToExtensions); + } + + expectedResult.Add("C:\\DiscoveryDummy.dll"); + + var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); + this.inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, null); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "DiscoverTests should call Initialize"); - Assert.IsTrue(manualResetEvent.WaitOne(5000)); - this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "DiscoverTests should not call Initialize if already initialized"); + Assert.IsFalse(expectedResult.Except(TestPluginCache.Instance.PathToExtensions).Any()); } [TestMethod] @@ -93,7 +89,7 @@ public void DiscoverTestsShouldCallDiscoveryManagerDiscoverTests() { var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); var mockTestDiscoveryEventsHandler = new Mock(); - var manualResetEvent = new ManualResetEvent(true); + var manualResetEvent = new ManualResetEvent(false); this.mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( () => manualResetEvent.Set()); @@ -108,7 +104,7 @@ public void DiscoverTestsShouldCatchExceptionAndCallHandleDiscoveryComplete() { var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); var mockTestDiscoveryEventsHandler = new Mock(); - var manualResetEvent = new ManualResetEvent(true); + var manualResetEvent = new ManualResetEvent(false); this.mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( () => throw new Exception()); @@ -124,7 +120,7 @@ public void DiscoverTestsShouldCatchExceptionAndCallHandleDiscoveryComplete() [TestMethod] public void AbortShouldCallDiscoveryManagerAbort() { - var manualResetEvent = new ManualResetEvent(true); + var manualResetEvent = new ManualResetEvent(false); this.mockDiscoveryManager.Setup(o => o.Abort()).Callback( () => manualResetEvent.Set()); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs index 1623672070..ab9c4d368f 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs @@ -7,11 +7,13 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Client using System.Collections.Generic; using System.Linq; using System.Threading; + using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; @@ -21,14 +23,16 @@ public class InProcessProxyExecutionManagerTests private Mock mockTestHostManagerFactory; private InProcessProxyExecutionManager inProcessProxyExecutionManager; private Mock mockExecutionManager; + private Mock mockTestHostManager; [TestInitialize] public void TestInitialize() { this.mockTestHostManagerFactory = new Mock(); this.mockExecutionManager = new Mock(); + this.mockTestHostManager = new Mock(); this.mockTestHostManagerFactory.Setup(o => o.GetExecutionManager()).Returns(this.mockExecutionManager.Object); - this.inProcessProxyExecutionManager = new InProcessProxyExecutionManager(this.mockTestHostManagerFactory.Object); + this.inProcessProxyExecutionManager = new InProcessProxyExecutionManager(this.mockTestHostManager.Object, this.mockTestHostManagerFactory.Object); } [TestCleanup] @@ -37,32 +41,12 @@ public void TestCleanup() this.mockExecutionManager = null; this.mockTestHostManagerFactory = null; this.inProcessProxyExecutionManager = null; + this.mockTestHostManager = null; } - [TestMethod] - public void InitializeShouldCallExecutionManagerInitializeWithEmptyIEnumerable() - { - this.inProcessProxyExecutionManager.Initialize(); - this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "ExecutionManager.Initialize() should get called with empty list"); - } - - [TestMethod] - public void InitializeShouldSetIsInitializedTotrue() - { - this.inProcessProxyExecutionManager.Initialize(); - Assert.IsTrue(this.inProcessProxyExecutionManager.IsInitialized, "ExecutionManager.Initialize() is not setting the value of varable IsInitialized to true"); - } - - [TestMethod] - public void InitializeShouldCallExecutionManagerInitializeWithEmptyIEnumerableOnlyOnce() - { - this.inProcessProxyExecutionManager.Initialize(); - this.inProcessProxyExecutionManager.Initialize(); - this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "ExecutionManager.Initialize() should get called once"); - } [TestMethod] - public void StartTestRunShouldCallInitializeIfNotAlreadyInitialized() + public void StartTestRunShouldCallInitialize() { var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); @@ -71,13 +55,20 @@ public void StartTestRunShouldCallInitializeIfNotAlreadyInitialized() } [TestMethod] - public void StartTestRunShouldNotCallInitializeIfAlreadyInitialized() + public void StartTestRunShouldUpdateTestPlauginCacheWithExtensionsReturnByTestHost() { + this.mockTestHostManager.Setup(o => o.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List { "C:\\dummy.dll" }); + List expectedResult = new List(); + if (TestPluginCache.Instance.PathToExtensions != null) + { + expectedResult.AddRange(TestPluginCache.Instance.PathToExtensions); + } + expectedResult.Add("C:\\dummy.dll"); + var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); - this.inProcessProxyExecutionManager.Initialize(); this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "StartTestRun should not call Initialize if already initialized"); + Assert.IsFalse(expectedResult.Except(TestPluginCache.Instance.PathToExtensions).Any()); } [TestMethod] diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs index 9f2523b2c0..d43ac2f8c6 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs @@ -49,8 +49,13 @@ public void GetDiscoveryManagerShouldReturnANonNullInstance() [TestMethod] public void GetDiscoveryManagerShouldReturnsNewInstanceOfProxyDiscoveryManagerIfTestHostIsShared() { - this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, null); + string settingXml = + @" + + true + + "; + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); var discoveryManager = this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig); Assert.AreNotSame(discoveryManager, this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig)); @@ -60,8 +65,13 @@ public void GetDiscoveryManagerShouldReturnsNewInstanceOfProxyDiscoveryManagerIf [TestMethod] public void GetDiscoveryManagerShouldReturnsParallelDiscoveryManagerIfTestHostIsNotShared() { - this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, null); + string settingXml = + @" + + true + + "; + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); this.testableTestRuntimeProvider = new TestableRuntimeProvider(false); Assert.IsNotNull(this.testEngine.GetDiscoveryManager(this.testableTestRuntimeProvider, discoveryCriteria, this.protocolConfig)); @@ -219,8 +229,7 @@ public void GetExecutionManagerShouldReturnNewInstance() [TestMethod] public void GetExecutionManagerShouldReturnDefaultExecutionManagerIfParallelDisabled() { - this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); - string settingXml = @""; + string settingXml = @"true"; var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100, false, settingXml); Assert.IsNotNull(this.testEngine.GetExecutionManager(this.testableTestRuntimeProvider, testRunCriteria, this.protocolConfig)); @@ -230,8 +239,13 @@ public void GetExecutionManagerShouldReturnDefaultExecutionManagerIfParallelDisa [TestMethod] public void GetExecutionManagerWithSingleSourceShouldReturnDefaultExecutionManagerEvenIfParallelEnabled() { - this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); - string settingXml = @"2"; + string settingXml = + @" + + 2 + true + + "; var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100, false, settingXml); Assert.IsNotNull(this.testEngine.GetExecutionManager(this.testableTestRuntimeProvider, testRunCriteria, this.protocolConfig)); @@ -251,9 +265,14 @@ public void GetExecutionManagerShouldReturnParallelExecutionManagerIfParallelEna [TestMethod] public void GetExecutionManagerShouldReturnParallelExecutionManagerIfHostIsNotShared() { - this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); + string settingXml = + @" + + true + + "; this.testableTestRuntimeProvider = new TestableRuntimeProvider(false); - var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, null); + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); Assert.IsNotNull(this.testEngine.GetExecutionManager(this.testableTestRuntimeProvider, testRunCriteria, this.protocolConfig)); Assert.IsInstanceOfType(this.testEngine.GetExecutionManager(this.testableTestRuntimeProvider, testRunCriteria, this.protocolConfig), typeof(ParallelProxyExecutionManager)); @@ -273,10 +292,10 @@ public void GetExcecutionManagerShouldReturnExectuionManagerWithDataCollectionIf [TestMethod] public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfInIsolationIsTrue() { - this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object, true); string settingXml = @" + true false false .NETFramework, Version=v4.5 diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs index f6664b565a..e2bf3791a7 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs @@ -10,8 +10,8 @@ namespace TestPlatform.CrossPlatEngine.UnitTests public class TestableTestEngine : TestEngine { - public TestableTestEngine(IProcessHelper processHelper, bool isInIsolation = false) - : base(TestRuntimeProviderManager.Instance, processHelper, isInIsolation) + public TestableTestEngine(IProcessHelper processHelper) + : base(TestRuntimeProviderManager.Instance, processHelper) { } } diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs index ba6b2430f6..17beca5499 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs @@ -33,6 +33,7 @@ public void RunConfigurationDefaultValuesMustBeUsedOnCreation() Assert.AreEqual(false, runConfiguration.DisableAppDomain); Assert.AreEqual(false, runConfiguration.DisableParallelization); Assert.AreEqual(false, runConfiguration.DesignMode); + Assert.AreEqual(false, runConfiguration.InIsolation); Assert.AreEqual(runConfiguration.DesignMode, runConfiguration.ShouldCollectSourceInformation); Assert.AreEqual(Constants.DefaultExecutionThreadApartmentState, runConfiguration.ExecutionThreadApartmentState); } @@ -75,6 +76,7 @@ public void RunConfigurationReadsValuesCorrectlyFromXml() C:\a\b;D:\x\y E:\x\z true + true false STA @@ -104,6 +106,7 @@ public void RunConfigurationReadsValuesCorrectlyFromXml() Assert.AreEqual(true, runConfiguration.DisableAppDomain); Assert.AreEqual(true, runConfiguration.DisableParallelization); Assert.AreEqual(true, runConfiguration.DesignMode); + Assert.AreEqual(true, runConfiguration.InIsolation); Assert.AreEqual(false, runConfiguration.ShouldCollectSourceInformation); Assert.AreEqual(PlatformApartmentState.STA, runConfiguration.ExecutionThreadApartmentState); } diff --git a/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs index ea24295e97..b69ff50974 100644 --- a/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs @@ -4,17 +4,21 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors { using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; using Microsoft.VisualStudio.TestTools.UnitTesting; + using vstest.console.UnitTests.Processors; [TestClass] public class InIsolationArgumentProcessorTests { private InIsolationArgumentExecutor executor; + private TestableRunSettingsProvider runSettingsProvider; [TestInitialize] public void Init() { - this.executor = new InIsolationArgumentExecutor(CommandLineOptions.Instance); + this.runSettingsProvider = new TestableRunSettingsProvider(); + this.executor = new InIsolationArgumentExecutor(CommandLineOptions.Instance, this.runSettingsProvider); } [TestCleanup] @@ -47,7 +51,7 @@ public void InIsolationArgumentProcessorMetadataShouldProvideAppropriateCapabili Assert.IsFalse(isolationProcessor.Metadata.Value.IsSpecialCommand); Assert.AreEqual(InIsolationArgumentProcessor.CommandName, isolationProcessor.Metadata.Value.CommandName); Assert.AreEqual(null, isolationProcessor.Metadata.Value.ShortCommandName); - Assert.AreEqual(ArgumentProcessorPriority.Normal, isolationProcessor.Metadata.Value.Priority); + Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, isolationProcessor.Metadata.Value.Priority); Assert.AreEqual(HelpContentPriority.InIsolationArgumentProcessorHelpPriority, isolationProcessor.Metadata.Value.HelpPriority); Assert.AreEqual("--InIsolation|/InIsolation\n Runs the tests in an isolated process. This makes vstest.console.exe \n process less likely to be stopped on an error in the tests, but tests \n may run slower.", isolationProcessor.Metadata.Value.HelpContentResourceName); } @@ -67,6 +71,7 @@ public void InitializeShouldSetInIsolationValue() { this.executor.Initialize(null); Assert.IsTrue(CommandLineOptions.Instance.InIsolation, "InProcess option must be set to true."); + Assert.AreEqual("true", this.runSettingsProvider.QueryRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath)); } [TestMethod] From ed5a9cabbe81c2601de2bafa898dfb58146fa0f3 Mon Sep 17 00:00:00 2001 From: faahmad Date: Tue, 29 Aug 2017 00:05:57 +0530 Subject: [PATCH 8/8] Append comment --- .../Client/InProcessProxyexecutionManager.cs | 1 + .../Client/ProxyExecutionManager.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs index 6f7117c290..1355e5f6d8 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs @@ -56,6 +56,7 @@ public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler e { try { + // This code should be in sync with ProxyExecutionManager.StartTestRun executionContext var executionContext = new TestExecutionContext( testRunCriteria.FrequencyOfRunStatsChangeEvent, testRunCriteria.RunStatsChangeEventTimeout, diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs index 9d8ee4d4f6..8357aae95b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs @@ -108,6 +108,7 @@ public virtual int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsH this.InitializeExtensions(testSources); + // This code should be in sync with InProcessProxyExecutionManager.StartTestRun executionContext var executionContext = new TestExecutionContext( testRunCriteria.FrequencyOfRunStatsChangeEvent, testRunCriteria.RunStatsChangeEventTimeout,