From 96bc4b02a77156d15e076ec83c3577133b087bd0 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Fri, 13 Dec 2019 14:42:29 +0530 Subject: [PATCH] Initialize only coverlet data collector --- .../Hosting/DotnetTestHostManager.cs | 4 ++-- .../Hosting/DotnetTestHostManagerTests.cs | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs index 6ad8619ec5..3408ef3a67 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs @@ -45,7 +45,7 @@ public class DotnetTestHostManager : ITestRuntimeProvider private const string DotnetTestHostUri = "HostProvider://DotnetTestHost"; private const string DotnetTestHostFriendlyName = "DotnetTestHost"; private const string TestAdapterRegexPattern = @"TestAdapter.dll"; - private const string DataCollectorRegexPattern = @"Collector.dll"; + private const string CoverletDataCollectorRegexPattern = @"coverlet.collector.dll"; private IDotnetHostHelper dotnetHostHelper; private IEnvironment platformEnvironment; @@ -318,7 +318,7 @@ public IEnumerable GetTestPlatformExtensions(IEnumerable sources if (extensions != null && extensions.Any()) { - extensionPaths.AddRange(extensions.Where(x => x.EndsWith(DataCollectorRegexPattern, StringComparison.OrdinalIgnoreCase))); + extensionPaths.AddRange(extensions.Where(x => x.EndsWith(CoverletDataCollectorRegexPattern, StringComparison.OrdinalIgnoreCase))); } return extensionPaths; diff --git a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs index 69b113746e..0ebecc7b2b 100644 --- a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs +++ b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs @@ -570,15 +570,25 @@ public void GetTestPlatformExtensionsShouldReturnEmptySetIfSourceDirectoryIsEmpt } [TestMethod] - public void GetTestPlatformExtensionsShouldAddDataCollectorsExtensionsIfPresent() + public void GetTestPlatformExtensionsShouldOnlyAddCoverletDataCollectorsExtensionsIfPresent() { this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(new[] { "foo.dll" }); - var extensions = this.dotnetHostManager.GetTestPlatformExtensions(this.testSource, new List { "abc.datacollector.dll" }); + var extensions = this.dotnetHostManager.GetTestPlatformExtensions(this.testSource, new List { "coverlet.collector.dll" }); Assert.AreEqual(1, extensions.Count()); } + [TestMethod] + public void GetTestPlatformExtensionsShouldNotAddNonCoverletDataCollectorsExtensionsIfPresent() + { + this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(new[] { "foo.dll" }); + var extensions = this.dotnetHostManager.GetTestPlatformExtensions(this.testSource, new List { "abc.dataollector.dll" }); + + Assert.AreEqual(0, extensions.Count()); + } + [TestMethod] public async Task LaunchTestHostShouldLaunchProcessWithConnectionInfo() {