From 98cfefc72de538a565dc71a191c25238a5a98635 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Thu, 5 Sep 2019 19:11:30 +0530 Subject: [PATCH 01/17] committing changes for #958 fix --- .../TesthostProtocol/IDiscoveryManager.cs | 2 +- .../TesthostProtocol/IExecutionManager.cs | 2 +- .../TestExtensionInitializeEventsHandler.cs | 66 +++++++++++++++++++ .../Client/InProcessProxyDiscoveryManager.cs | 2 +- .../Client/InProcessProxyexecutionManager.cs | 2 +- .../Discovery/DiscoveryManager.cs | 4 +- .../EventHandlers/TestRequestHandler.cs | 6 +- .../Execution/ExecutionManager.cs | 28 +++++++- .../InProcessProxyDiscoveryManagerTests.cs | 7 +- .../InProcessProxyexecutionManagerTests.cs | 3 +- .../Discovery/DiscoveryManagerTests.cs | 3 +- .../EventHandlers/TestRequestHandlerTests.cs | 7 +- .../Execution/ExecutionManagerTests.cs | 4 +- 13 files changed, 115 insertions(+), 21 deletions(-) create mode 100644 src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestExtensionInitializeEventsHandler.cs diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IDiscoveryManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IDiscoveryManager.cs index 400a1eb27d..e60787a968 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IDiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IDiscoveryManager.cs @@ -16,7 +16,7 @@ public interface IDiscoveryManager /// Initializes the discovery manager. /// /// The path to additional extensions. - void Initialize(IEnumerable pathToAdditionalExtensions); + void Initialize(IEnumerable pathToAdditionalExtensions, ITestDiscoveryEventsHandler2 eventHandler); /// /// Discovers tests diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IExecutionManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IExecutionManager.cs index 2576e5154f..7828159fca 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IExecutionManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IExecutionManager.cs @@ -18,7 +18,7 @@ public interface IExecutionManager /// Initializes the execution manager. /// /// The path to additional extensions. - void Initialize(IEnumerable pathToAdditionalExtensions); + void Initialize(IEnumerable pathToAdditionalExtensions, ITestMessageEventHandler testMessageEventsHandler); /// /// Starts the test run with sources. diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestExtensionInitializeEventsHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestExtensionInitializeEventsHandler.cs new file mode 100644 index 0000000000..df87735458 --- /dev/null +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestExtensionInitializeEventsHandler.cs @@ -0,0 +1,66 @@ +// 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.CommunicationUtilities.EventHandlers +{ + using System; + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + + /// + /// The test run events handler. + /// + public class TestExtensionInitializeEventsHandler : ITestMessageEventHandler + { + private ITestRequestHandler requestHandler; + + /// + /// Initializes a new instance of the class. + /// + /// test request handler + public TestExtensionInitializeEventsHandler(ITestRequestHandler requestHandler) + { + this.requestHandler = requestHandler; + } + + /// + /// Handles a test run message. + /// + /// The level. + /// The message. + public void HandleLogMessage(TestMessageLevel level, string message) + { + switch ((TestMessageLevel)level) + { + case TestMessageLevel.Informational: + EqtTrace.Info(message); + break; + + case TestMessageLevel.Warning: + EqtTrace.Warning(message); + break; + + case TestMessageLevel.Error: + EqtTrace.Error(message); + break; + + default: + EqtTrace.Info(message); + break; + } + + this.requestHandler.SendLog(level, message); + } + + public void HandleRawMessage(string rawMessage) + { + // No-Op + // TestHost at this point has no functionality where it requires rawmessage + } + } +} diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs index 88ebc83041..db1baf2d1a 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs @@ -105,7 +105,7 @@ private void InitializeExtensions(IEnumerable sources) // 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()); + discoveryManager.Initialize(Enumerable.Empty(), null); } } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs index 97e7d3aacd..5371a5f53b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs @@ -144,7 +144,7 @@ private void InitializeExtensions(IEnumerable sources) // 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()); + executionManager.Initialize(Enumerable.Empty(), null); } } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs index 0f724688bf..51ce7a68b2 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs @@ -63,10 +63,10 @@ protected DiscoveryManager(IRequestData requestData, ITestPlatformEventSource te /// Initializes the discovery manager. /// /// The path to additional extensions. - public void Initialize(IEnumerable pathToAdditionalExtensions) + public void Initialize(IEnumerable pathToAdditionalExtensions, ITestDiscoveryEventsHandler2 eventHandler) { this.testPlatformEventSource.AdapterSearchStart(); - + this.testDiscoveryEventsHandler = eventHandler; if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Any()) { // Start using these additional extensions diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs index b6c81e7fc6..c615d14174 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs @@ -240,10 +240,11 @@ public void OnMessageReceived(object sender, MessageReceivedEventArgs messageRec { EqtTrace.Info("Discovery Session Initialize."); this.testHostManagerFactoryReady.Wait(); + var discoveryEventsHandler = new TestDiscoveryEventHandler(this); var pathToAdditionalExtensions = this.dataSerializer.DeserializePayload>(message); jobQueue.QueueJob( () => - testHostManagerFactory.GetDiscoveryManager().Initialize(pathToAdditionalExtensions), 0); + testHostManagerFactory.GetDiscoveryManager().Initialize(pathToAdditionalExtensions, discoveryEventsHandler), 0); break; } @@ -265,10 +266,11 @@ public void OnMessageReceived(object sender, MessageReceivedEventArgs messageRec { EqtTrace.Info("Execution Session Initialize."); this.testHostManagerFactoryReady.Wait(); + var testExtensionInitializeEventsHandler = new TestExtensionInitializeEventsHandler(this); var pathToAdditionalExtensions = this.dataSerializer.DeserializePayload>(message); jobQueue.QueueJob( () => - testHostManagerFactory.GetExecutionManager().Initialize(pathToAdditionalExtensions), 0); + testHostManagerFactory.GetExecutionManager().Initialize(pathToAdditionalExtensions, testExtensionInitializeEventsHandler), 0); break; } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs index 9a94039b62..1bce54d289 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs @@ -8,6 +8,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution using System.Linq; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + using Microsoft.VisualStudio.TestPlatform.Common.Logging; using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; @@ -20,6 +21,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution 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; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; /// @@ -28,16 +30,35 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution public class ExecutionManager : IExecutionManager { private readonly ITestPlatformEventSource testPlatformEventSource; - private BaseRunTests activeTestRun; - private IRequestData requestData; + private readonly TestSessionMessageLogger sessionMessageLogger; + private ITestMessageEventHandler testMessageEventsHandler; /// /// Initializes a new instance of the class. /// public ExecutionManager(IRequestData requestData) : this(TestPlatformEventSource.Instance, requestData) { + this.sessionMessageLogger = TestSessionMessageLogger.Instance; + this.sessionMessageLogger.TestRunMessage += this.TestSessionMessageHandler; + } + + private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) + { + if (this.testMessageEventsHandler != null) + { + this.testMessageEventsHandler.HandleLogMessage(e.Level, e.Message); + } + else + { + if (EqtTrace.IsWarningEnabled) + { + EqtTrace.Warning( + "ExecutionManager: Could not pass the log message '{0}' as the callback is null.", + e.Message); + } + } } /// @@ -56,8 +77,9 @@ protected ExecutionManager(ITestPlatformEventSource testPlatformEventSource, IRe /// Initializes the execution manager. /// /// The path to additional extensions. - public void Initialize(IEnumerable pathToAdditionalExtensions) + public void Initialize(IEnumerable pathToAdditionalExtensions, ITestMessageEventHandler testMessageEventsHandler) { + this.testMessageEventsHandler = testMessageEventsHandler; this.testPlatformEventSource.AdapterSearchStart(); if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Any()) diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs index 688344b21e..ab6d88f3dd 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs @@ -48,8 +48,8 @@ public void TestCleanup() public void DiscoverTestsShouldCallInitialize() { var manualResetEvent = new ManualResetEvent(false); - - this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty())).Callback( + var mockTestDiscoveryEventHandler = new Mock(); + this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty(), mockTestDiscoveryEventHandler.Object)).Callback( () => manualResetEvent.Set()); var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); @@ -62,7 +62,8 @@ public void DiscoverTestsShouldCallInitialize() public void DiscoverTestsShouldUpdateTestPluginCacheWithExtensionsReturnByTestHost() { var manualResetEvent = new ManualResetEvent(false); - this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty())).Callback( + var mockTestDiscoveryEventHandler = new Mock(); + this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty(), mockTestDiscoveryEventHandler.Object)).Callback( () => manualResetEvent.Set()); this.mockTestHostManager.Setup(o => o.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List { "C:\\DiscoveryDummy.dll" }); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs index 47851d21e7..da541f9037 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs @@ -48,9 +48,10 @@ public void TestCleanup() public void StartTestRunShouldCallInitialize() { var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); + var mockTestMessageEventHandler = new Mock(); this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty()), Times.Once, "StartTestRun should call Initialize if not already initialized"); + this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty(), mockTestMessageEventHandler.Object), Times.Once, "StartTestRun should call Initialize if not already initialized"); } [TestMethod] diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs index 622c2c5583..915c9cc7d7 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs @@ -52,11 +52,12 @@ public void TestCleanup() public void InitializeShouldUpdateAdditionalExtenions() { var mockFileHelper = new Mock(); + var mockLogger = new Mock(); mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(false); TestPluginCache.Instance = new TestableTestPluginCache(); this.discoveryManager.Initialize( - new string[] { typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location }); + new string[] { typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location }, mockLogger.Object); var allDiscoverers = TestDiscoveryExtensionManager.Create().Discoverers; diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs index 912aa8ee75..8b01383442 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs @@ -174,12 +174,13 @@ public void ProcessRequestsVersionCheckShouldLogErrorIfDiagnosticsEnableFails() public void ProcessRequestsDiscoveryInitializeShouldSetExtensionPaths() { var message = this.dataSerializer.SerializePayload(MessageType.DiscoveryInitialize, new[] { "testadapter.dll" }); + var mockTestDiscoveryEventHandler = new Mock(); this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); this.SendMessageOnChannel(message); this.jobQueue.Flush(); - this.mockDiscoveryManager.Verify(d => d.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))))); + this.mockDiscoveryManager.Verify(d => d.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))), mockTestDiscoveryEventHandler.Object)); this.SendSessionEnd(); } @@ -218,13 +219,13 @@ public void DiscoveryCompleteShouldSendDiscoveryCompletePayloadOnChannel() public void ProcessRequestsExecutionInitializeShouldSetExtensionPaths() { var message = this.dataSerializer.SerializePayload(MessageType.ExecutionInitialize, new[] { "testadapter.dll" }); - + var mockTestDiscoveryEventHandler = new Mock(); this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); this.SendMessageOnChannel(message); this.jobQueue.Flush(); - this.mockExecutionManager.Verify(e => e.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))))); + this.mockExecutionManager.Verify(e => e.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))), mockTestDiscoveryEventHandler.Object)); this.SendSessionEnd(); } diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs index 6bc96678c4..30938889ce 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs @@ -74,13 +74,13 @@ public void TestCleanup() public void InitializeShouldLoadAndInitializeAllExtension() { var commonAssemblyLocation = typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location; - + var mockTestMessageEventHandler = new Mock(); TestPluginCacheTests.SetupMockExtensions( new string[] { commonAssemblyLocation }, () => { }); - this.executionManager.Initialize(new List { commonAssemblyLocation }); + this.executionManager.Initialize(new List { commonAssemblyLocation }, mockTestMessageEventHandler.Object); Assert.IsNotNull(TestPluginCache.Instance.TestExtensions); From 5081873ba7b233a7b61dfee23a97c01a92363f45 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Thu, 5 Sep 2019 19:25:03 +0530 Subject: [PATCH 02/17] committing changes for #958 fix --- .../ExtensionFramework/TestPluginDiscoverer.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs index 8aed93ac90..838272c773 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs @@ -12,7 +12,9 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework using System.Reflection; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; + using Microsoft.VisualStudio.TestPlatform.Common.Logging; using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; @@ -138,6 +140,12 @@ private void GetTestExtensionsFromFiles( this.GetTestExtensionsFromAssembly(assembly, pluginInfos); } } + catch (FileLoadException e) + { + EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); + string fileLoadErrorMessage = $"TestPluginDiscoverer: Failed to load extensions from file '" + file + "'"; + TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Error, fileLoadErrorMessage); + } catch (Exception e) { EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); From f7bb50cd450d8a6c2c5f9812140da3e07cc374f8 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Fri, 6 Sep 2019 17:46:10 +0530 Subject: [PATCH 03/17] committing tests fixes #958 --- .../Client/InProcessProxyDiscoveryManagerTests.cs | 2 +- .../Client/InProcessProxyexecutionManagerTests.cs | 2 +- .../EventHandlers/TestRequestHandlerTests.cs | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs index ab6d88f3dd..5e4809f4c9 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs @@ -49,7 +49,7 @@ public void DiscoverTestsShouldCallInitialize() { var manualResetEvent = new ManualResetEvent(false); var mockTestDiscoveryEventHandler = new Mock(); - this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty(), mockTestDiscoveryEventHandler.Object)).Callback( + this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty(), null)).Callback( () => manualResetEvent.Set()); var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs index da541f9037..0003712027 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs @@ -51,7 +51,7 @@ public void StartTestRunShouldCallInitialize() var mockTestMessageEventHandler = new Mock(); this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty(), mockTestMessageEventHandler.Object), Times.Once, "StartTestRun should call Initialize if not already initialized"); + this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty(), It.IsAny()), Times.Once, "StartTestRun should call Initialize if not already initialized"); } [TestMethod] diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs index 8b01383442..4b5d5a2d24 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs @@ -174,13 +174,12 @@ public void ProcessRequestsVersionCheckShouldLogErrorIfDiagnosticsEnableFails() public void ProcessRequestsDiscoveryInitializeShouldSetExtensionPaths() { var message = this.dataSerializer.SerializePayload(MessageType.DiscoveryInitialize, new[] { "testadapter.dll" }); - var mockTestDiscoveryEventHandler = new Mock(); this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); this.SendMessageOnChannel(message); this.jobQueue.Flush(); - this.mockDiscoveryManager.Verify(d => d.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))), mockTestDiscoveryEventHandler.Object)); + this.mockDiscoveryManager.Verify(d => d.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))), It.IsAny())); this.SendSessionEnd(); } @@ -219,13 +218,12 @@ public void DiscoveryCompleteShouldSendDiscoveryCompletePayloadOnChannel() public void ProcessRequestsExecutionInitializeShouldSetExtensionPaths() { var message = this.dataSerializer.SerializePayload(MessageType.ExecutionInitialize, new[] { "testadapter.dll" }); - var mockTestDiscoveryEventHandler = new Mock(); this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); this.SendMessageOnChannel(message); this.jobQueue.Flush(); - this.mockExecutionManager.Verify(e => e.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))), mockTestDiscoveryEventHandler.Object)); + this.mockExecutionManager.Verify(e => e.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))), It.IsAny())); this.SendSessionEnd(); } From 3d2ceeb5a51b1324451edd118956ca26a6997a08 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Fri, 6 Sep 2019 18:21:47 +0530 Subject: [PATCH 04/17] commtting fixes for tests #958 --- .../Client/InProcessProxyDiscoveryManagerTests.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs index 5e4809f4c9..451af19c94 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs @@ -48,7 +48,6 @@ public void TestCleanup() public void DiscoverTestsShouldCallInitialize() { var manualResetEvent = new ManualResetEvent(false); - var mockTestDiscoveryEventHandler = new Mock(); this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty(), null)).Callback( () => manualResetEvent.Set()); @@ -62,8 +61,7 @@ public void DiscoverTestsShouldCallInitialize() public void DiscoverTestsShouldUpdateTestPluginCacheWithExtensionsReturnByTestHost() { var manualResetEvent = new ManualResetEvent(false); - var mockTestDiscoveryEventHandler = new Mock(); - this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty(), mockTestDiscoveryEventHandler.Object)).Callback( + this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty(), null)).Callback( () => manualResetEvent.Set()); this.mockTestHostManager.Setup(o => o.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List { "C:\\DiscoveryDummy.dll" }); From 520272c874c5e4be8426b994dc5c52cb50330eee Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Tue, 10 Sep 2019 17:29:56 +0530 Subject: [PATCH 05/17] Updated handle class name and downgraded TestMessageLevel Error to Warning --- .../ExtensionFramework/TestPluginDiscoverer.cs | 10 ++++++---- .../Resources/Resources.Designer.cs | 15 ++++++++++++--- .../Resources/Resources.resx | 3 +++ .../Resources/xlf/Resources.cs.xlf | 5 +++++ .../Resources/xlf/Resources.de.xlf | 5 +++++ .../Resources/xlf/Resources.es.xlf | 5 +++++ .../Resources/xlf/Resources.fr.xlf | 5 +++++ .../Resources/xlf/Resources.it.xlf | 5 +++++ .../Resources/xlf/Resources.ja.xlf | 5 +++++ .../Resources/xlf/Resources.ko.xlf | 5 +++++ .../Resources/xlf/Resources.pl.xlf | 5 +++++ .../Resources/xlf/Resources.pt-BR.xlf | 5 +++++ .../Resources/xlf/Resources.ru.xlf | 5 +++++ .../Resources/xlf/Resources.tr.xlf | 5 +++++ .../Resources/xlf/Resources.xlf | 5 +++++ .../Resources/xlf/Resources.zh-Hans.xlf | 5 +++++ .../Resources/xlf/Resources.zh-Hant.xlf | 5 +++++ ...sHandler.cs => TestInitializeEventsHandler.cs} | 6 +++--- .../Discovery/DiscoveryManager.cs | 5 +++++ .../EventHandlers/TestRequestHandler.cs | 4 ++-- .../Execution/ExecutionManager.cs | 13 +++++++++---- .../Resources/xlf/Resources.pt-BR.xlf | 6 ++---- 22 files changed, 112 insertions(+), 20 deletions(-) rename src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/{TestExtensionInitializeEventsHandler.cs => TestInitializeEventsHandler.cs} (88%) diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs index 838272c773..6b96ec6f90 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs @@ -7,6 +7,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; + using System.Globalization; using System.IO; using System.Linq; using System.Reflection; @@ -17,6 +18,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + using CommonResources = Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources; /// /// Discovers test extensions in a directory. @@ -141,10 +143,10 @@ private void GetTestExtensionsFromFiles( } } catch (FileLoadException e) - { - EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); - string fileLoadErrorMessage = $"TestPluginDiscoverer: Failed to load extensions from file '" + file + "'"; - TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Error, fileLoadErrorMessage); + { + EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); + string fileLoadErrorMessage = string.Format(CultureInfo.CurrentUICulture, CommonResources.FailedToLoadAdapaterFile, file); + TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Warning, fileLoadErrorMessage); } catch (Exception e) { diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs index 8dfb3feae7..0208ee5061 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs @@ -11,8 +11,8 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.Resources { using System; using System.Reflection; - - + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -40,7 +40,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources", typeof(Resources).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; @@ -169,6 +169,15 @@ internal static string FailedToFindInstalledUnitTestExtensions { } } + /// + /// Looks up a localized string similar to TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.. + /// + internal static string FailedToLoadAdapaterFile { + get { + return ResourceManager.GetString("FailedToLoadAdapaterFile", resourceCulture); + } + } + /// /// Looks up a localized string similar to An error occured while creating Fast filter.. /// diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx index 450bf809c0..473e0cc63f 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx @@ -153,6 +153,9 @@ Failed to find the list of installed unit test extensions. Reason: {0} + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + An error occured while creating Fast filter. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf index 66ef328d0b..72d9b857bc 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf @@ -269,6 +269,11 @@ Operace se ruší na základě žádosti. + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf index 0a849def77..a7e1d53b06 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf @@ -269,6 +269,11 @@ Der Vorgang wird gemäß Anforderung abgebrochen. + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf index 37a25b277e..e3da51058f 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf @@ -269,6 +269,11 @@ La operación se cancelará como se ha solicitado. + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf index 223b1eb528..63da24e11a 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf @@ -269,6 +269,11 @@ Annulation de l'opération, comme demandé. + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf index 538357807d..b85dde07b5 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf @@ -269,6 +269,11 @@ L'operazione verrà annullata come richiesto. + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf index ff37a71693..e94a8034b9 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf @@ -269,6 +269,11 @@ 操作のキャンセルが要求されたため、キャンセルしています。 + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf index 31ebab2400..b41dd85dd7 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf @@ -269,6 +269,11 @@ 요청한 대로 작업을 취소하는 중입니다. + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf index 2ed8d83aac..82fec0533d 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf @@ -269,6 +269,11 @@ Anulowanie operacji zgodnie z żądaniem. + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf index 1f57678b09..2765c13f2a 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf @@ -269,6 +269,11 @@ Cancelando a operação conforme solicitado. + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf index 56ec3f06e3..a665db9220 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf @@ -269,6 +269,11 @@ Операция отменяется в соответствии с запросом. + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf index 36aa10339c..f23fe6d43e 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf @@ -269,6 +269,11 @@ İşlem istek üzerine iptal ediliyor. + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf index a89f0855a0..31afce1b04 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf @@ -146,6 +146,11 @@ Cancelling the operation as requested. + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf index b0c5218f28..e963fd4736 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf @@ -269,6 +269,11 @@ 按要求取消该操作。 + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf index 5c3231c90d..f982930eaf 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf @@ -269,6 +269,11 @@ 正在應要求取消作業。 + + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestExtensionInitializeEventsHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestInitializeEventsHandler.cs similarity index 88% rename from src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestExtensionInitializeEventsHandler.cs rename to src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestInitializeEventsHandler.cs index df87735458..64b7ba6194 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestExtensionInitializeEventsHandler.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestInitializeEventsHandler.cs @@ -15,15 +15,15 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.EventHandle /// /// The test run events handler. /// - public class TestExtensionInitializeEventsHandler : ITestMessageEventHandler + public class TestInitializeEventsHandler : ITestMessageEventHandler { private ITestRequestHandler requestHandler; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// test request handler - public TestExtensionInitializeEventsHandler(ITestRequestHandler requestHandler) + public TestInitializeEventsHandler(ITestRequestHandler requestHandler) { this.requestHandler = requestHandler; } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs index 51ce7a68b2..bf43b7082a 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs @@ -247,6 +247,11 @@ private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) if (this.testDiscoveryEventsHandler != null) { + if (e.Level == TestMessageLevel.Error) + { + // Downgrade the message severity to Warning... + e.Level = TestMessageLevel.Warning; + } this.testDiscoveryEventsHandler.HandleLogMessage(e.Level, e.Message); } else diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs index c615d14174..3149b022d9 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs @@ -266,11 +266,11 @@ public void OnMessageReceived(object sender, MessageReceivedEventArgs messageRec { EqtTrace.Info("Execution Session Initialize."); this.testHostManagerFactoryReady.Wait(); - var testExtensionInitializeEventsHandler = new TestExtensionInitializeEventsHandler(this); + var testInitializeEventsHandler = new TestInitializeEventsHandler(this); var pathToAdditionalExtensions = this.dataSerializer.DeserializePayload>(message); jobQueue.QueueJob( () => - testHostManagerFactory.GetExecutionManager().Initialize(pathToAdditionalExtensions, testExtensionInitializeEventsHandler), 0); + testHostManagerFactory.GetExecutionManager().Initialize(pathToAdditionalExtensions, testInitializeEventsHandler), 0); break; } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs index 1bce54d289..0abbc97832 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs @@ -48,6 +48,11 @@ private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) { if (this.testMessageEventsHandler != null) { + if (e.Level == TestMessageLevel.Error) + { + // Downgrade the message severity to Warning... + e.Level = TestMessageLevel.Warning; + } this.testMessageEventsHandler.HandleLogMessage(e.Level, e.Message); } else @@ -118,7 +123,7 @@ public void StartTestRun( this.activeTestRun.RunTests(); } - catch(Exception e) + catch (Exception e) { runEventsHandler.HandleLogMessage(ObjectModel.Logging.TestMessageLevel.Error, e.ToString()); this.Abort(runEventsHandler); @@ -149,12 +154,12 @@ public void StartTestRun( try { this.InitializeDataCollectors(runSettings, testCaseEventsHandler as ITestEventsPublisher, TestSourcesUtility.GetDefaultCodebasePath(tests)); - + this.activeTestRun = new RunTestsWithTests(this.requestData, tests, package, runSettings, testExecutionContext, testCaseEventsHandler, runEventsHandler); this.activeTestRun.RunTests(); } - catch(Exception e) + catch (Exception e) { runEventsHandler.HandleLogMessage(ObjectModel.Logging.TestMessageLevel.Error, e.ToString()); this.Abort(runEventsHandler); @@ -237,7 +242,7 @@ private void InitializeDataCollectors(string runSettings, ITestEventsPublisher t { var outOfProcDataCollectionManager = new ProxyOutOfProcDataCollectionManager(DataCollectionTestCaseEventSender.Instance, testEventsPublisher); } - + // Initialize inproc data collectors if declared in run settings. if (XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(runSettings)) { diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf index 87ddd99aa1..a647b1b972 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf @@ -155,8 +155,7 @@ Testhost process exited with error: {0}. Please check the diagnostic logs for more information. O processo do testhost foi encerrado com o erro: {0}. Verifique os logs de diagnóstico para obter mais informações. - - + DataCollector debugging is enabled. Please attach debugger to datacollector process to continue. @@ -206,8 +205,7 @@ Discovery of tests cancelled. Descoberta de testes cancelada. - - + From e89a48c35fd66d04773c9ee141fd57f906e56756 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Thu, 12 Sep 2019 20:12:28 +0530 Subject: [PATCH 06/17] commit changes to print specific error messages in each case of adapter load fail --- src/Microsoft.TestPlatform.Common/Constants.cs | 15 ++++++++++++++- .../ExtensionFramework/TestPluginDiscoverer.cs | 5 +++-- .../Resources/Resources.Designer.cs | 11 +++++------ .../Resources/Resources.resx | 2 +- .../Resources/xlf/Resources.cs.xlf | 2 +- .../Resources/xlf/Resources.de.xlf | 2 +- .../Resources/xlf/Resources.es.xlf | 2 +- .../Resources/xlf/Resources.fr.xlf | 2 +- .../Resources/xlf/Resources.it.xlf | 2 +- .../Resources/xlf/Resources.ja.xlf | 2 +- .../Resources/xlf/Resources.ko.xlf | 2 +- .../Resources/xlf/Resources.pl.xlf | 2 +- .../Resources/xlf/Resources.pt-BR.xlf | 2 +- .../Resources/xlf/Resources.ru.xlf | 2 +- .../Resources/xlf/Resources.tr.xlf | 2 +- .../Resources/xlf/Resources.xlf | 2 +- .../Resources/xlf/Resources.zh-Hans.xlf | 2 +- .../Resources/xlf/Resources.zh-Hant.xlf | 2 +- 18 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/Constants.cs b/src/Microsoft.TestPlatform.Common/Constants.cs index 93a6988e5a..01ddf21c58 100644 --- a/src/Microsoft.TestPlatform.Common/Constants.cs +++ b/src/Microsoft.TestPlatform.Common/Constants.cs @@ -1,8 +1,11 @@ // 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.Common { + using System.Collections.Generic; /// /// Defines the defaults used across different components. /// @@ -12,7 +15,7 @@ public static class TestPlatformDefaults /// string in the vstest.console.exe.config that specifies the bound on no of jobs in the job queue. /// public const string MaxNumberOfEventsLoggerEventQueueCanHold = "MaxNumberOfEventsLoggerEventQueueCanHold"; - + /// /// Default bound on the job queue. /// @@ -63,5 +66,15 @@ public static class TestPlatformConstants /// Pattern used to find the run time providers library using String.EndWith /// public const string RunTimeEndsWithPattern = @"RuntimeProvider.dll"; + + /// + /// entensionTypeInfo lists the type info of extensions + /// + public static readonly IList entensionTypeInfo = new List() + { + {"TestExecutorPluginInformation"}, + {"TestDiscovererPluginInformation"}, + {"TestSettingsProviderPluginInformation"} + }; } } diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs index 6b96ec6f90..f2c68c07f0 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework using System.IO; using System.Linq; using System.Reflection; - + using System.Xml; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; using Microsoft.VisualStudio.TestPlatform.Common.Logging; using Microsoft.VisualStudio.TestPlatform.ObjectModel; @@ -145,7 +145,8 @@ private void GetTestExtensionsFromFiles( catch (FileLoadException e) { EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); - string fileLoadErrorMessage = string.Format(CultureInfo.CurrentUICulture, CommonResources.FailedToLoadAdapaterFile, file); + string entensionTypeInfo = TestPlatformConstants.entensionTypeInfo.Where(x => x.Equals(pluginInfos.GetType().GetGenericArguments()[1].GetTypeInfo().Name)).Select(x=>x).FirstOrDefault().ToString(); + string fileLoadErrorMessage = string.Format(CultureInfo.CurrentUICulture, CommonResources.FailedToLoadAdapaterFile, entensionTypeInfo, file); TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Warning, fileLoadErrorMessage); } catch (Exception e) diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs index 0208ee5061..3a1fce708d 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs @@ -10,9 +10,8 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.Resources { using System; - using System.Reflection; - - + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -20,7 +19,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.Resources { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -170,14 +169,14 @@ internal static string FailedToFindInstalledUnitTestExtensions { } /// - /// Looks up a localized string similar to TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.. + /// Looks up a localized string similar to The extension of type '{0}' is failed to load extensions from file '{1}'.. /// internal static string FailedToLoadAdapaterFile { get { return ResourceManager.GetString("FailedToLoadAdapaterFile", resourceCulture); } } - + /// /// Looks up a localized string similar to An error occured while creating Fast filter.. /// diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx index 473e0cc63f..8eb1ede2a5 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx @@ -154,7 +154,7 @@ Failed to find the list of installed unit test extensions. Reason: {0} - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. An error occured while creating Fast filter. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf index 72d9b857bc..b7c2569b08 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf index a7e1d53b06..aaed7025c3 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf index e3da51058f..94120bb069 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf index 63da24e11a..f198446743 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf index b85dde07b5..f0c4664dfc 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf index e94a8034b9..efd163d620 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf index b41dd85dd7..728a4ec29d 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf index 82fec0533d..702667a856 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf index 2765c13f2a..0408b7f7a5 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf index a665db9220..9335e047cb 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf index f23fe6d43e..82acb9a782 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf index 31afce1b04..2c2f95a3da 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf @@ -147,7 +147,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf index e963fd4736..19d4f55f74 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf index f982930eaf..22dec6872e 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf @@ -270,7 +270,7 @@ - TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + The extension of type '{0}' is failed to load extensions from file '{1}'. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. From 65418b7a6e56541d8d655ad8a9dbfc32237c02c5 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Fri, 13 Sep 2019 19:22:19 +0530 Subject: [PATCH 07/17] committing new tests for #958 --- .../TestPluginDiscoverer.cs | 26 ++++++---- .../Resources/Resources.Designer.cs | 2 +- .../Resources/Resources.resx | 2 +- .../Resources/xlf/Resources.cs.xlf | 2 +- .../Resources/xlf/Resources.de.xlf | 2 +- .../Resources/xlf/Resources.es.xlf | 2 +- .../Resources/xlf/Resources.fr.xlf | 2 +- .../Resources/xlf/Resources.it.xlf | 2 +- .../Resources/xlf/Resources.ja.xlf | 2 +- .../Resources/xlf/Resources.ko.xlf | 2 +- .../Resources/xlf/Resources.pl.xlf | 2 +- .../Resources/xlf/Resources.pt-BR.xlf | 2 +- .../Resources/xlf/Resources.ru.xlf | 2 +- .../Resources/xlf/Resources.tr.xlf | 2 +- .../Resources/xlf/Resources.xlf | 2 +- .../Resources/xlf/Resources.zh-Hans.xlf | 2 +- .../Resources/xlf/Resources.zh-Hant.xlf | 2 +- .../Discovery/DiscoveryManagerTests.cs | 25 ++++++++- .../Execution/ExecutionManagerTests.cs | 52 +++++++++++++++++-- 19 files changed, 104 insertions(+), 31 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs index f2c68c07f0..21cd6ca15c 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs @@ -27,6 +27,8 @@ internal class TestPluginDiscoverer { private IFileHelper fileHelper; + private static List UnloadableFiles = new List(); + /// /// Initializes a new instance of the class. /// @@ -103,7 +105,7 @@ private void AddKnownExtensions(ref IEnumerable extensionPaths) // In UWP .Net Native Compilation mode managed dll's are packaged differently, & File.Exists() fails. // Include these two dll's if so far no adapters(extensions) were found, & let Assembly.Load() fail if they are not present. extensionPaths = extensionPaths.Concat(new[] { "Microsoft.VisualStudio.TestTools.CppUnitTestFramework.CppUnitTestExtension.dll", "Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter.dll" }); - } + } /// /// Gets test extension information from the given colletion of files. @@ -132,6 +134,10 @@ private void GetTestExtensionsFromFiles( // Scan each of the files for data extensions. foreach (var file in files) { + if(UnloadableFiles.Contains(file)) + { + continue; + } try { Assembly assembly = null; @@ -142,17 +148,16 @@ private void GetTestExtensionsFromFiles( this.GetTestExtensionsFromAssembly(assembly, pluginInfos); } } - catch (FileLoadException e) - { - EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); - string entensionTypeInfo = TestPlatformConstants.entensionTypeInfo.Where(x => x.Equals(pluginInfos.GetType().GetGenericArguments()[1].GetTypeInfo().Name)).Select(x=>x).FirstOrDefault().ToString(); - string fileLoadErrorMessage = string.Format(CultureInfo.CurrentUICulture, CommonResources.FailedToLoadAdapaterFile, entensionTypeInfo, file); - TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Warning, fileLoadErrorMessage); - } catch (Exception e) { EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); - continue; + + if (e is FileLoadException) + { + string fileLoadErrorMessage = string.Format(CultureInfo.CurrentUICulture, CommonResources.FailedToLoadAdapaterFile, file); + TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Warning, fileLoadErrorMessage); + UnloadableFiles.Add(file); + } } } } @@ -172,8 +177,8 @@ private void GetTestExtensionsFromAssembly(Assembly ass { Debug.Assert(assembly != null, "null assembly"); Debug.Assert(pluginInfos != null, "null pluginInfos"); - Type[] types; + try { types = assembly.GetTypes(); @@ -189,7 +194,6 @@ private void GetTestExtensionsFromAssembly(Assembly ass EqtTrace.Warning("LoaderExceptions: {0}", ex); } } - return; } diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs index 3a1fce708d..08e4897357 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs @@ -169,7 +169,7 @@ internal static string FailedToFindInstalledUnitTestExtensions { } /// - /// Looks up a localized string similar to The extension of type '{0}' is failed to load extensions from file '{1}'.. + /// Looks up a localized string similar to Failed to load extensions from file '{0}'. Please use /diag for more information.. /// internal static string FailedToLoadAdapaterFile { get { diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx index 8eb1ede2a5..8e03b8fcdb 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx @@ -154,7 +154,7 @@ Failed to find the list of installed unit test extensions. Reason: {0} - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. An error occured while creating Fast filter. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf index b7c2569b08..66e157470b 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf index aaed7025c3..9d6b73864f 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf index 94120bb069..4d3bcaa7e1 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf index f198446743..0516749dbe 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf index f0c4664dfc..d5f51a31bf 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf index efd163d620..751f4150bf 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf index 728a4ec29d..ffe3f7311b 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf index 702667a856..93081acbba 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf index 0408b7f7a5..85c6c0b355 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf index 9335e047cb..c326d2179d 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf index 82acb9a782..42bb585f21 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf index 2c2f95a3da..e83ed26f2b 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf @@ -147,7 +147,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf index 19d4f55f74..9fd21e69a7 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf index 22dec6872e..af7b8773d7 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf @@ -270,7 +270,7 @@ - The extension of type '{0}' is failed to load extensions from file '{1}'. + Failed to load extensions from file '{0}'. Please use /diag for more information. TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs index 915c9cc7d7..191ee46b5d 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs @@ -10,10 +10,12 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery using System.Reflection; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + using Microsoft.VisualStudio.TestPlatform.Common.Logging; using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -29,12 +31,14 @@ public class DiscoveryManagerTests private DiscoveryManager discoveryManager; private Mock mockRequestData; private Mock mockMetricsCollection; + private TestSessionMessageLogger sessionLogger; [TestInitialize] public void TestInit() { this.mockRequestData = new Mock(); this.mockMetricsCollection = new Mock(); + this.sessionLogger = TestSessionMessageLogger.Instance; this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); this.discoveryManager = new DiscoveryManager(this.mockRequestData.Object); } @@ -148,7 +152,7 @@ public void DiscoverTestsShouldDiscoverTestsInTheSpecifiedSource() var mockLogger = new Mock(); this.discoveryManager.DiscoverTests(criteria, mockLogger.Object); - + // Assert that the tests are passed on via the handletestruncomplete event. mockLogger.Verify(l => l.HandleDiscoveryComplete(It.IsAny(), It.IsAny>()), Times.Once); } @@ -222,6 +226,25 @@ public void DiscoverTestsShouldCollectMetrics() mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsDiscovered, It.IsAny()), Times.Once); } + [TestMethod] + public void DiscoveryInitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() + { + var assemblyLocation = typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location; + var mockLogger = new Mock(); + TestPluginCacheTests.SetupMockExtensions( + new string[] { assemblyLocation }, + () => { }); + + //Act + this.discoveryManager.Initialize(new List { assemblyLocation }, mockLogger.Object); + + //when handler instance returns warning + sessionLogger.SendMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"); + + // Verify. + mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"), Times.Once); + } + #endregion } } diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs index 30938889ce..016db9bf62 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs @@ -11,6 +11,7 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Execution using Microsoft.VisualStudio.TestPlatform.Common; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; + using Microsoft.VisualStudio.TestPlatform.Common.Logging; using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; @@ -33,16 +34,18 @@ public class ExecutionManagerTests private ExecutionManager executionManager; private TestExecutionContext testExecutionContext; private Mock mockRequestData; + private TestSessionMessageLogger sessionLogger; [TestInitialize] public void TestInit() { this.mockRequestData = new Mock(); this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); + this.sessionLogger = TestSessionMessageLogger.Instance; this.executionManager = new ExecutionManager(new RequestData - { - MetricsCollection = new NoOpMetricsCollection() - }); + { + MetricsCollection = new NoOpMetricsCollection() + }); TestPluginCache.Instance = null; @@ -210,5 +213,48 @@ public void StartTestRunShouldAbortTheRunIfAnyExceptionComesForTheProvidedSource mockTestRunEventsHandler.Verify(treh => treh.HandleTestRunComplete(It.IsAny(), null, null, null), Times.Once); mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); } + + [TestMethod] + public void InitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() + { + var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; + var mockLogger = new Mock(); + TestPluginCacheTests.SetupMockExtensions( + new string[] { assemblyLocation }, + () => { }); + + //Act + this.executionManager.Initialize(new List { assemblyLocation }, mockLogger.Object); + + //when handler instance returns warning + sessionLogger.SendMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"); + + // Verify. + mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"), Times.Once); + } + + [TestMethod] + public void InitializeShouldVerifyThatItIsNotNullIfAdapterFailedToLoad() + { + var mockLogger = new Mock(); + + //when handler instance is not null + sessionLogger.SendMessage(TestMessageLevel.Informational, "verify that it is not null"); + + // Verify. + mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Informational, "verify that it is not null"), Times.Never); + } + + [TestMethod] + public void InitializeShouldVerifyThatItIsNullIfAdapterFailedToLoad() + { + var mockLogger = new Mock(); + + //when handler instance is null + sessionLogger.SendMessage(It.IsAny(), "verify null"); + + // Verify. + mockLogger.Verify(rd => rd.HandleLogMessage(It.IsAny(), "verify null"), Times.Never); + } } } From c291d2d70c52caa48eee9c57cfba984d0e739a0e Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Mon, 16 Sep 2019 16:01:56 +0530 Subject: [PATCH 08/17] Code changes refined #958 --- src/Microsoft.TestPlatform.Common/Constants.cs | 10 ---------- .../Discovery/DiscovererEnumerator.cs | 7 +++---- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/Constants.cs b/src/Microsoft.TestPlatform.Common/Constants.cs index 01ddf21c58..7f5f7d6fb5 100644 --- a/src/Microsoft.TestPlatform.Common/Constants.cs +++ b/src/Microsoft.TestPlatform.Common/Constants.cs @@ -66,15 +66,5 @@ public static class TestPlatformConstants /// Pattern used to find the run time providers library using String.EndWith /// public const string RunTimeEndsWithPattern = @"RuntimeProvider.dll"; - - /// - /// entensionTypeInfo lists the type info of extensions - /// - public static readonly IList entensionTypeInfo = new List() - { - {"TestExecutorPluginInformation"}, - {"TestDiscovererPluginInformation"}, - {"TestSettingsProviderPluginInformation"} - }; } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs index 48666d0c3d..cde5d9fc65 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs @@ -166,7 +166,7 @@ private void LoadTestsFromAnExtension(string extensionAssembly, IEnumerable sources, s } else { - logger.SendMessage( - TestMessageLevel.Warning, - string.Format( + //Should be logged only when tests found - if adapter failed to load then there would be no tests to process + EqtTrace.Warning(string.Format( CultureInfo.CurrentUICulture, CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, sourcesString)); From 1fc1a8a6755362b60e3caa15ae71e0b1caf56e56 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Mon, 16 Sep 2019 16:34:21 +0530 Subject: [PATCH 09/17] LogWarningOnNoTestsDiscovered change reverted --- .../Discovery/DiscovererEnumerator.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs index cde5d9fc65..1b56fdb8ac 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs @@ -317,10 +317,11 @@ private static void LogWarningOnNoTestsDiscovered(IEnumerable sources, s else { //Should be logged only when tests found - if adapter failed to load then there would be no tests to process - EqtTrace.Warning(string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, - sourcesString)); + logger.SendMessage( + TestMessageLevel.Warning, string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, + sourcesString)); } } From 40f5291924d0b2891ad0dd8db27aed9aec863f7e Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Thu, 19 Sep 2019 17:47:47 +0530 Subject: [PATCH 10/17] commit changes improve test results --- src/vstest.console/Internal/ConsoleLogger.cs | 22 +++++++++++++++---- .../Internal/Interfaces/IProgressIndicator.cs | 6 +++++ .../Internal/ProgressIndicator.cs | 20 ++++++++++++++++- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/vstest.console/Internal/ConsoleLogger.cs b/src/vstest.console/Internal/ConsoleLogger.cs index de6e74da9b..816f23ddd2 100644 --- a/src/vstest.console/Internal/ConsoleLogger.cs +++ b/src/vstest.console/Internal/ConsoleLogger.cs @@ -112,6 +112,7 @@ internal enum Verbosity private int testsFailed = 0; private int testsSkipped = 0; private bool testRunHasErrorMessages = false; + private string testsStatus = string.Empty; #endregion @@ -505,7 +506,9 @@ private void TestResultHandler(object sender, TestResultEventArgs e) } // Resume the progress indicator after displaying the test result information - this.progressIndicator?.Start(); + + UpdateTestsStatus(); + this.progressIndicator?.Start(testsStatus); break; } @@ -526,7 +529,8 @@ private void TestResultHandler(object sender, TestResultEventArgs e) DisplayFullInformation(e.Result); // Resume the progress indicator after displaying the test result information - this.progressIndicator?.Start(); + UpdateTestsStatus(); + this.progressIndicator?.Start(testsStatus); break; } @@ -547,7 +551,8 @@ private void TestResultHandler(object sender, TestResultEventArgs e) } // Resume the progress indicator after displaying the test result information - this.progressIndicator?.Start(); + UpdateTestsStatus(); + this.progressIndicator?.Start(testsStatus); } break; @@ -571,7 +576,8 @@ private void TestResultHandler(object sender, TestResultEventArgs e) } // Resume the progress indicator after displaying the test result information - this.progressIndicator?.Start(); + UpdateTestsStatus(); + this.progressIndicator?.Start(testsStatus); break; } @@ -700,5 +706,13 @@ public static void RaiseTestRunWarning(string warningMessage) Output.Warning(AppendPrefix, warningMessage); } + + /// + /// updates the test results + /// + public void UpdateTestsStatus() + { + testsStatus = "| Executed :" + testsTotal + " | Passed :" + testsPassed + " | Failed: " + testsFailed + " | Skipped: " + testsSkipped + ""; + } } } diff --git a/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs b/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs index 79110adbd1..5ef9abc353 100644 --- a/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs +++ b/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs @@ -10,6 +10,12 @@ internal interface IProgressIndicator /// void Start(); + /// + /// Marks the start of the progress indicator + /// + /// + void Start(string testsStatus); + /// /// Pause the progress indicator /// diff --git a/src/vstest.console/Internal/ProgressIndicator.cs b/src/vstest.console/Internal/ProgressIndicator.cs index 429fab10fe..06eacb12db 100644 --- a/src/vstest.console/Internal/ProgressIndicator.cs +++ b/src/vstest.console/Internal/ProgressIndicator.cs @@ -38,7 +38,6 @@ public ProgressIndicator(IOutput output, IConsoleHelper consoleHelper) this.ConsoleHelper = consoleHelper; this.testRunProgressString = string.Format(CultureInfo.CurrentCulture, "{0}...", Resources.Resources.ProgressIndicatorString); } - /// public void Start() { @@ -58,6 +57,25 @@ public void Start() } } + /// + public void Start(string testsStatus) + { + lock (syncObject) + { + if (timer == null) + { + this.timer = new Timer(1000); + this.timer.Elapsed += Timer_Elapsed; + this.timer.Start(); + } + + // Print the string based on the previous state, that is dotCounter + // This is required for smooth transition + this.ConsoleOutput.Write(testRunProgressString.Substring(0, testRunProgressString.Length + dotCounter - 2)+testsStatus, OutputLevel.Information); + this.IsRunning = true; + } + } + /// // Get the current cursor position // Clear the console starting given position From 8dbee95a56f760ebecacc75944da2fa7fefe5a5f Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Thu, 19 Sep 2019 18:43:59 +0530 Subject: [PATCH 11/17] commit latest changes --- .../Constants.cs | 1 - .../Discovery/DiscovererEnumerator.cs | 3 +- .../Execution/ExecutionManager.cs | 44 +++++++++---------- src/vstest.console/Internal/ConsoleLogger.cs | 28 +++--------- .../Internal/Interfaces/IProgressIndicator.cs | 6 --- .../Internal/ProgressIndicator.cs | 19 -------- 6 files changed, 30 insertions(+), 71 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/Constants.cs b/src/Microsoft.TestPlatform.Common/Constants.cs index 7f5f7d6fb5..e4d9351b49 100644 --- a/src/Microsoft.TestPlatform.Common/Constants.cs +++ b/src/Microsoft.TestPlatform.Common/Constants.cs @@ -5,7 +5,6 @@ namespace Microsoft.VisualStudio.TestPlatform.Common { - using System.Collections.Generic; /// /// Defines the defaults used across different components. /// diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs index 1b56fdb8ac..993ecba0e4 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs @@ -166,7 +166,7 @@ private void LoadTestsFromAnExtension(string extensionAssembly, IEnumerable sources, s } else { - //Should be logged only when tests found - if adapter failed to load then there would be no tests to process logger.SendMessage( TestMessageLevel.Warning, string.Format( CultureInfo.CurrentUICulture, diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs index 0abbc97832..96aa61675f 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs @@ -44,28 +44,6 @@ public ExecutionManager(IRequestData requestData) : this(TestPlatformEventSource this.sessionMessageLogger.TestRunMessage += this.TestSessionMessageHandler; } - private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) - { - if (this.testMessageEventsHandler != null) - { - if (e.Level == TestMessageLevel.Error) - { - // Downgrade the message severity to Warning... - e.Level = TestMessageLevel.Warning; - } - this.testMessageEventsHandler.HandleLogMessage(e.Level, e.Message); - } - else - { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning( - "ExecutionManager: Could not pass the log message '{0}' as the callback is null.", - e.Message); - } - } - } - /// /// Initializes a new instance of the class. /// @@ -96,6 +74,7 @@ public void Initialize(IEnumerable pathToAdditionalExtensions, ITestMess this.LoadExtensions(); this.testPlatformEventSource.AdapterSearchStop(); + this.sessionMessageLogger.TestRunMessage -= this.TestSessionMessageHandler; } /// @@ -250,6 +229,27 @@ private void InitializeDataCollectors(string runSettings, ITestEventsPublisher t } } + private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) + { + if (this.testMessageEventsHandler != null) + { + if (e.Level == TestMessageLevel.Error) + { + // Downgrade the message severity to Warning... + e.Level = TestMessageLevel.Warning; + } + this.testMessageEventsHandler.HandleLogMessage(e.Level, e.Message); + } + else + { + if (EqtTrace.IsWarningEnabled) + { + EqtTrace.Warning( + "ExecutionManager: Could not pass the log message '{0}' as the callback is null.", + e.Message); + } + } + } #endregion } } diff --git a/src/vstest.console/Internal/ConsoleLogger.cs b/src/vstest.console/Internal/ConsoleLogger.cs index 816f23ddd2..0cf49302d9 100644 --- a/src/vstest.console/Internal/ConsoleLogger.cs +++ b/src/vstest.console/Internal/ConsoleLogger.cs @@ -112,7 +112,6 @@ internal enum Verbosity private int testsFailed = 0; private int testsSkipped = 0; private bool testRunHasErrorMessages = false; - private string testsStatus = string.Empty; #endregion @@ -182,7 +181,7 @@ public void Initialize(TestLoggerEvents events, string testRunDirectory) // Progress indicator needs to be displayed only for cli experience. this.progressIndicator = new ProgressIndicator(Output, new ConsoleHelper()); } - + // Register for the events. events.TestRunMessage += this.TestMessageHandler; events.TestResult += this.TestResultHandler; @@ -505,10 +504,8 @@ private void TestResultHandler(object sender, TestResultEventArgs e) DisplayFullInformation(e.Result); } - // Resume the progress indicator after displaying the test result information - - UpdateTestsStatus(); - this.progressIndicator?.Start(testsStatus); + // Resume the progress indicator after displaying the test result informationUpdateTestsStatus(); + this.progressIndicator?.Start(); break; } @@ -520,7 +517,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e) { break; } - + // Pause the progress indicator before displaying test result information this.progressIndicator?.Pause(); @@ -529,8 +526,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e) DisplayFullInformation(e.Result); // Resume the progress indicator after displaying the test result information - UpdateTestsStatus(); - this.progressIndicator?.Start(testsStatus); + this.progressIndicator?.Start(); break; } @@ -551,8 +547,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e) } // Resume the progress indicator after displaying the test result information - UpdateTestsStatus(); - this.progressIndicator?.Start(testsStatus); + this.progressIndicator?.Start(); } break; @@ -576,8 +571,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e) } // Resume the progress indicator after displaying the test result information - UpdateTestsStatus(); - this.progressIndicator?.Start(testsStatus); + this.progressIndicator?.Start(); break; } @@ -706,13 +700,5 @@ public static void RaiseTestRunWarning(string warningMessage) Output.Warning(AppendPrefix, warningMessage); } - - /// - /// updates the test results - /// - public void UpdateTestsStatus() - { - testsStatus = "| Executed :" + testsTotal + " | Passed :" + testsPassed + " | Failed: " + testsFailed + " | Skipped: " + testsSkipped + ""; - } } } diff --git a/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs b/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs index 5ef9abc353..79110adbd1 100644 --- a/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs +++ b/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs @@ -10,12 +10,6 @@ internal interface IProgressIndicator /// void Start(); - /// - /// Marks the start of the progress indicator - /// - /// - void Start(string testsStatus); - /// /// Pause the progress indicator /// diff --git a/src/vstest.console/Internal/ProgressIndicator.cs b/src/vstest.console/Internal/ProgressIndicator.cs index 06eacb12db..07e382f612 100644 --- a/src/vstest.console/Internal/ProgressIndicator.cs +++ b/src/vstest.console/Internal/ProgressIndicator.cs @@ -57,25 +57,6 @@ public void Start() } } - /// - public void Start(string testsStatus) - { - lock (syncObject) - { - if (timer == null) - { - this.timer = new Timer(1000); - this.timer.Elapsed += Timer_Elapsed; - this.timer.Start(); - } - - // Print the string based on the previous state, that is dotCounter - // This is required for smooth transition - this.ConsoleOutput.Write(testRunProgressString.Substring(0, testRunProgressString.Length + dotCounter - 2)+testsStatus, OutputLevel.Information); - this.IsRunning = true; - } - } - /// // Get the current cursor position // Clear the console starting given position From 04101444bd78163154d4ccd8dd3717a639f91940 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Fri, 20 Sep 2019 17:08:31 +0530 Subject: [PATCH 12/17] commtting latest changes --- .../ExtensionFramework/TestPluginDiscoverer.cs | 18 +++++++++--------- .../Discovery/DiscoveryManager.cs | 2 ++ .../Execution/ExecutionManager.cs | 8 ++++++-- .../Execution/ExecutionManagerTests.cs | 5 ++--- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs index 21cd6ca15c..af000b0ec9 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs @@ -105,7 +105,7 @@ private void AddKnownExtensions(ref IEnumerable extensionPaths) // In UWP .Net Native Compilation mode managed dll's are packaged differently, & File.Exists() fails. // Include these two dll's if so far no adapters(extensions) were found, & let Assembly.Load() fail if they are not present. extensionPaths = extensionPaths.Concat(new[] { "Microsoft.VisualStudio.TestTools.CppUnitTestFramework.CppUnitTestExtension.dll", "Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter.dll" }); - } + } /// /// Gets test extension information from the given colletion of files. @@ -134,7 +134,7 @@ private void GetTestExtensionsFromFiles( // Scan each of the files for data extensions. foreach (var file in files) { - if(UnloadableFiles.Contains(file)) + if (UnloadableFiles.Contains(file)) { continue; } @@ -148,16 +148,16 @@ private void GetTestExtensionsFromFiles( this.GetTestExtensionsFromAssembly(assembly, pluginInfos); } } + catch (FileLoadException e) + { + EqtTrace.Warning("TestPluginDiscoverer-FileLoadException: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); + string fileLoadErrorMessage = string.Format(CultureInfo.CurrentUICulture, CommonResources.FailedToLoadAdapaterFile, file); + TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Warning, fileLoadErrorMessage); + UnloadableFiles.Add(file); + } catch (Exception e) { EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); - - if (e is FileLoadException) - { - string fileLoadErrorMessage = string.Format(CultureInfo.CurrentUICulture, CommonResources.FailedToLoadAdapaterFile, file); - TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Warning, fileLoadErrorMessage); - UnloadableFiles.Add(file); - } } } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs index bf43b7082a..6764616bb6 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs @@ -76,6 +76,7 @@ public void Initialize(IEnumerable pathToAdditionalExtensions, ITestDisc // Load and Initialize extensions. TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false); this.testPlatformEventSource.AdapterSearchStop(); + this.testDiscoveryEventsHandler = null; } /// @@ -107,6 +108,7 @@ public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEve } } + this.sessionMessageLogger.TestRunMessage -= this.TestSessionMessageHandler; // If there are sources to discover if (verifiedExtensionSourceMap.Any()) { diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs index 96aa61675f..373994dc0f 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs @@ -73,8 +73,7 @@ public void Initialize(IEnumerable pathToAdditionalExtensions, ITestMess this.LoadExtensions(); - this.testPlatformEventSource.AdapterSearchStop(); - this.sessionMessageLogger.TestRunMessage -= this.TestSessionMessageHandler; + this.testPlatformEventSource.AdapterSearchStop(); } /// @@ -94,6 +93,8 @@ public void StartTestRun( ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler runEventsHandler) { + //unsubscrive session logger + this.sessionMessageLogger.TestRunMessage -= this.TestSessionMessageHandler; try { this.InitializeDataCollectors(runSettings, testCaseEventsHandler as ITestEventsPublisher, TestSourcesUtility.GetDefaultCodebasePath(adapterSourceMap)); @@ -137,6 +138,7 @@ public void StartTestRun( this.activeTestRun = new RunTestsWithTests(this.requestData, tests, package, runSettings, testExecutionContext, testCaseEventsHandler, runEventsHandler); this.activeTestRun.RunTests(); + } catch (Exception e) { @@ -250,6 +252,8 @@ private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) } } } + + #endregion } } diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs index 016db9bf62..bcfb37e83c 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs @@ -220,9 +220,8 @@ public void InitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; var mockLogger = new Mock(); TestPluginCacheTests.SetupMockExtensions( - new string[] { assemblyLocation }, - () => { }); - + new string[] { assemblyLocation }, + () => { }); //Act this.executionManager.Initialize(new List { assemblyLocation }, mockLogger.Object); From afd4420b7788c0a8e62afa255eea0b6a829036ff Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Fri, 20 Sep 2019 17:38:23 +0530 Subject: [PATCH 13/17] Reverted TestRunMessage handler unsubscription --- .../Discovery/DiscoveryManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs index 6764616bb6..db3beee5f7 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs @@ -108,7 +108,6 @@ public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEve } } - this.sessionMessageLogger.TestRunMessage -= this.TestSessionMessageHandler; // If there are sources to discover if (verifiedExtensionSourceMap.Any()) { From 7211af98bf98ee99a5a449c3bb2310c19bce7c75 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Fri, 20 Sep 2019 18:27:26 +0530 Subject: [PATCH 14/17] Unsubscribed testRunMessage session --- .../Discovery/DiscoveryManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs index db3beee5f7..783ddcbef9 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs @@ -76,7 +76,7 @@ public void Initialize(IEnumerable pathToAdditionalExtensions, ITestDisc // Load and Initialize extensions. TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false); this.testPlatformEventSource.AdapterSearchStop(); - this.testDiscoveryEventsHandler = null; + } /// @@ -108,6 +108,8 @@ public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEve } } + //unsubscribe TestRunMessage session + this.sessionMessageLogger.TestRunMessage -= this.TestSessionMessageHandler; // If there are sources to discover if (verifiedExtensionSourceMap.Any()) { From 6ab126a4f2c2154cc4928e49b03811610e387d66 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Fri, 20 Sep 2019 19:26:00 +0530 Subject: [PATCH 15/17] latest changes --- .../Discovery/DiscoveryManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs index 783ddcbef9..ed0746a1fb 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs @@ -108,8 +108,7 @@ public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEve } } - //unsubscribe TestRunMessage session - this.sessionMessageLogger.TestRunMessage -= this.TestSessionMessageHandler; + // If there are sources to discover if (verifiedExtensionSourceMap.Any()) { From c38ecaebdf6a7a1a0c8148f0eb6abf0405f81760 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Mon, 23 Sep 2019 16:54:55 +0530 Subject: [PATCH 16/17] Amendments have been done --- .../Constants.cs | 4 +- .../Discovery/DiscovererEnumerator.cs | 9 ++-- .../Discovery/DiscoveryManager.cs | 5 -- .../Execution/ExecutionManager.cs | 11 ++-- src/vstest.console/Internal/ConsoleLogger.cs | 4 +- .../Internal/Interfaces/IProgressIndicator.cs | 2 +- .../Internal/ProgressIndicator.cs | 3 +- .../Discovery/DiscoveryManagerTests.cs | 4 +- .../Execution/ExecutionManagerTests.cs | 52 +++++++------------ 9 files changed, 36 insertions(+), 58 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/Constants.cs b/src/Microsoft.TestPlatform.Common/Constants.cs index e4d9351b49..fbee6e3f20 100644 --- a/src/Microsoft.TestPlatform.Common/Constants.cs +++ b/src/Microsoft.TestPlatform.Common/Constants.cs @@ -1,8 +1,6 @@ // 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.Common { /// @@ -66,4 +64,4 @@ public static class TestPlatformConstants /// public const string RunTimeEndsWithPattern = @"RuntimeProvider.dll"; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs index 993ecba0e4..48666d0c3d 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs @@ -317,10 +317,11 @@ private static void LogWarningOnNoTestsDiscovered(IEnumerable sources, s else { logger.SendMessage( - TestMessageLevel.Warning, string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, - sourcesString)); + TestMessageLevel.Warning, + string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, + sourcesString)); } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs index ed0746a1fb..a266585f5f 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs @@ -249,11 +249,6 @@ private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) if (this.testDiscoveryEventsHandler != null) { - if (e.Level == TestMessageLevel.Error) - { - // Downgrade the message severity to Warning... - e.Level = TestMessageLevel.Warning; - } this.testDiscoveryEventsHandler.HandleLogMessage(e.Level, e.Message); } else diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs index 373994dc0f..25b0dd299e 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs @@ -73,6 +73,9 @@ public void Initialize(IEnumerable pathToAdditionalExtensions, ITestMess this.LoadExtensions(); + //unsubscrive session logger + this.sessionMessageLogger.TestRunMessage -= this.TestSessionMessageHandler; + this.testPlatformEventSource.AdapterSearchStop(); } @@ -93,8 +96,6 @@ public void StartTestRun( ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler runEventsHandler) { - //unsubscrive session logger - this.sessionMessageLogger.TestRunMessage -= this.TestSessionMessageHandler; try { this.InitializeDataCollectors(runSettings, testCaseEventsHandler as ITestEventsPublisher, TestSourcesUtility.GetDefaultCodebasePath(adapterSourceMap)); @@ -235,11 +236,6 @@ private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) { if (this.testMessageEventsHandler != null) { - if (e.Level == TestMessageLevel.Error) - { - // Downgrade the message severity to Warning... - e.Level = TestMessageLevel.Warning; - } this.testMessageEventsHandler.HandleLogMessage(e.Level, e.Message); } else @@ -253,7 +249,6 @@ private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) } } - #endregion } } diff --git a/src/vstest.console/Internal/ConsoleLogger.cs b/src/vstest.console/Internal/ConsoleLogger.cs index 0cf49302d9..b3ba4d9a74 100644 --- a/src/vstest.console/Internal/ConsoleLogger.cs +++ b/src/vstest.console/Internal/ConsoleLogger.cs @@ -504,7 +504,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e) DisplayFullInformation(e.Result); } - // Resume the progress indicator after displaying the test result informationUpdateTestsStatus(); + // Resume the progress indicator after displaying the test result information this.progressIndicator?.Start(); break; @@ -701,4 +701,4 @@ public static void RaiseTestRunWarning(string warningMessage) Output.Warning(AppendPrefix, warningMessage); } } -} +} \ No newline at end of file diff --git a/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs b/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs index 79110adbd1..f50ea6c647 100644 --- a/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs +++ b/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs @@ -20,4 +20,4 @@ internal interface IProgressIndicator /// void Stop(); } -} +} \ No newline at end of file diff --git a/src/vstest.console/Internal/ProgressIndicator.cs b/src/vstest.console/Internal/ProgressIndicator.cs index 07e382f612..a331d88e1c 100644 --- a/src/vstest.console/Internal/ProgressIndicator.cs +++ b/src/vstest.console/Internal/ProgressIndicator.cs @@ -38,6 +38,7 @@ public ProgressIndicator(IOutput output, IConsoleHelper consoleHelper) this.ConsoleHelper = consoleHelper; this.testRunProgressString = string.Format(CultureInfo.CurrentCulture, "{0}...", Resources.Resources.ProgressIndicatorString); } + /// public void Start() { @@ -113,4 +114,4 @@ private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs index 191ee46b5d..fd01fbd8ce 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs @@ -239,10 +239,10 @@ public void DiscoveryInitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() this.discoveryManager.Initialize(new List { assemblyLocation }, mockLogger.Object); //when handler instance returns warning - sessionLogger.SendMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"); + sessionLogger.SendMessage(TestMessageLevel.Warning, "verify that the HandleLogMessage method getting invoked at least once"); // Verify. - mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"), Times.Once); + mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Warning, "verify that the HandleLogMessage method getting invoked at least once"), Times.Once); } #endregion diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs index bcfb37e83c..8424a56775 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs @@ -214,46 +214,34 @@ public void StartTestRunShouldAbortTheRunIfAnyExceptionComesForTheProvidedSource mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); } - [TestMethod] - public void InitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() - { - var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; - var mockLogger = new Mock(); - TestPluginCacheTests.SetupMockExtensions( - new string[] { assemblyLocation }, - () => { }); - //Act - this.executionManager.Initialize(new List { assemblyLocation }, mockLogger.Object); - - //when handler instance returns warning - sessionLogger.SendMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"); - - // Verify. - mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"), Times.Once); - } + //[TestMethod] + //public void InitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() + //{ + // var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; + // var mockLogger = new Mock(); + // TestPluginCacheTests.SetupMockExtensions( + // new string[] { assemblyLocation }, + // () => { }); + // //Act + // this.executionManager.Initialize(new List { assemblyLocation }, mockLogger.Object); + + // //when handler instance returns warning + // sessionLogger.SendMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"); + + // // Verify. + // mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"), Times.Once); + //} [TestMethod] - public void InitializeShouldVerifyThatItIsNotNullIfAdapterFailedToLoad() + public void InitializeShouldVerifyTheHandlerInitializationWhenAdapterIsFailedToLoad() { var mockLogger = new Mock(); - //when handler instance is not null - sessionLogger.SendMessage(TestMessageLevel.Informational, "verify that it is not null"); - - // Verify. - mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Informational, "verify that it is not null"), Times.Never); - } - - [TestMethod] - public void InitializeShouldVerifyThatItIsNullIfAdapterFailedToLoad() - { - var mockLogger = new Mock(); - //when handler instance is null - sessionLogger.SendMessage(It.IsAny(), "verify null"); + sessionLogger.SendMessage(It.IsAny(), "verify that the HandleLogMessage method will not be invoked when handler is not initialized"); // Verify. - mockLogger.Verify(rd => rd.HandleLogMessage(It.IsAny(), "verify null"), Times.Never); + mockLogger.Verify(rd => rd.HandleLogMessage(It.IsAny(), "verify that the HandleLogMessage method will not be invoked when handler is not initialized"), Times.Never); } } } From 96f69f6fa653bf84b274fdac189b2ef0dfc155e6 Mon Sep 17 00:00:00 2001 From: DineshChirnanchu Date: Wed, 25 Sep 2019 15:32:02 +0530 Subject: [PATCH 17/17] Format corrected --- src/Microsoft.TestPlatform.Common/Constants.cs | 2 +- src/vstest.console/Internal/ConsoleLogger.cs | 2 +- src/vstest.console/Internal/Interfaces/IProgressIndicator.cs | 2 +- src/vstest.console/Internal/ProgressIndicator.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/Constants.cs b/src/Microsoft.TestPlatform.Common/Constants.cs index fbee6e3f20..9f86b7f26b 100644 --- a/src/Microsoft.TestPlatform.Common/Constants.cs +++ b/src/Microsoft.TestPlatform.Common/Constants.cs @@ -64,4 +64,4 @@ public static class TestPlatformConstants /// public const string RunTimeEndsWithPattern = @"RuntimeProvider.dll"; } -} \ No newline at end of file +} diff --git a/src/vstest.console/Internal/ConsoleLogger.cs b/src/vstest.console/Internal/ConsoleLogger.cs index b3ba4d9a74..9a2c8367d0 100644 --- a/src/vstest.console/Internal/ConsoleLogger.cs +++ b/src/vstest.console/Internal/ConsoleLogger.cs @@ -701,4 +701,4 @@ public static void RaiseTestRunWarning(string warningMessage) Output.Warning(AppendPrefix, warningMessage); } } -} \ No newline at end of file +} diff --git a/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs b/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs index f50ea6c647..79110adbd1 100644 --- a/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs +++ b/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs @@ -20,4 +20,4 @@ internal interface IProgressIndicator /// void Stop(); } -} \ No newline at end of file +} diff --git a/src/vstest.console/Internal/ProgressIndicator.cs b/src/vstest.console/Internal/ProgressIndicator.cs index a331d88e1c..429fab10fe 100644 --- a/src/vstest.console/Internal/ProgressIndicator.cs +++ b/src/vstest.console/Internal/ProgressIndicator.cs @@ -114,4 +114,4 @@ private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) } } } -} \ No newline at end of file +}