diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs index 07c15ac150..c2b3c6796a 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs @@ -37,6 +37,12 @@ internal class ProxyExecutionManager : ProxyOperationManager, IProxyExecutionMan private bool skipDefaultAdapters; private readonly IFileHelper fileHelper; + // Only send coverlet inproc datacollector dll to be initialized via testhost, + // ideally this should get initialized via InProcessDC Node in runsettings, but + // somehow it is failing, hence putting this ugly HACK, to fix issues like + // https://developercommunity.visualstudio.com/content/problem/738856/could-not-load-file-or-assembly-microsoftintellitr.html + private const string CoverletDataCollector = "coverlet.collector.dll"; + /// public bool IsInitialized { get; private set; } = false; @@ -261,7 +267,9 @@ private void LogMessage(TestMessageLevel testMessageLevel, string message) private void InitializeExtensions(IEnumerable sources) { var extensions = TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.TestAdapterEndsWithPattern, this.skipDefaultAdapters); - extensions = extensions.Concat(TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.DataCollectorEndsWithPattern, true)).ToList(); + + // remove this line once we figure out why coverlet inproc DC is not initialized via runsetting inproc node. + extensions = extensions.Concat(TestPluginCache.Instance.GetExtensionPaths(ProxyExecutionManager.CoverletDataCollector, true)).ToList(); // Filter out non existing extensions var nonExistingExtensions = extensions.Where(extension => !this.fileHelper.Exists(extension)); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs index 1f00950e37..33f9635197 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs @@ -303,11 +303,11 @@ public void StartTestRunShouldInitializeExtensionsWithExistingExtensionsOnly() } [TestMethod] - public void StartTestRunShouldInitializeExtensionsWithExistingDataCOllectorExtensions() + public void StartTestRunShouldInitializeExtensionsOnlyWithCoverletDataCollectorExtensions() { TestPluginCache.Instance = null; - TestPluginCache.Instance.UpdateExtensions(new List { "abc.TestAdapter.dll", "def.TestAdapter.dll", "xyz.TestAdapter.dll", "abc.DataCollector.dll" }, false); - var expectedOutputPaths = new[] { "abc.TestAdapter.dll", "xyz.TestAdapter.dll", "abc.DataCollector.dll" }; + TestPluginCache.Instance.UpdateExtensions(new List { "abc.TestAdapter.dll", "def.TestAdapter.dll", "xyz.TestAdapter.dll", "abc.DataCollector.dll", "xyz.coverlet.collector.dll" }, false); + var expectedOutputPaths = new[] { "abc.TestAdapter.dll", "xyz.TestAdapter.dll", "xyz.coverlet.collector.dll" }; this.mockTestHostManager.SetupGet(th => th.Shared).Returns(false); this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); @@ -324,6 +324,7 @@ public void StartTestRunShouldInitializeExtensionsWithExistingDataCOllectorExten this.mockFileHelper.Setup(fh => fh.Exists("abc.TestAdapter.dll")).Returns(true); this.mockFileHelper.Setup(fh => fh.Exists("xyz.TestAdapter.dll")).Returns(true); this.mockFileHelper.Setup(fh => fh.Exists("abc.DataCollector.dll")).Returns(true); + this.mockFileHelper.Setup(fh => fh.Exists("xyz.coverlet.collector.dll")).Returns(true); var mockTestRunEventsHandler = new Mock(); this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object);