Skip to content

Commit

Permalink
Initialize only coverlet data collector (#2274)
Browse files Browse the repository at this point in the history
  • Loading branch information
vagisha-nidhi authored and mayankbansal018 committed Dec 16, 2019
1 parent 2eea2f1 commit fd77fc8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -318,7 +318,7 @@ public IEnumerable<string> GetTestPlatformExtensions(IEnumerable<string> 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;
Expand Down
Expand Up @@ -570,15 +570,25 @@ public void GetTestPlatformExtensionsShouldReturnEmptySetIfSourceDirectoryIsEmpt
}

[TestMethod]
public void GetTestPlatformExtensionsShouldAddDataCollectorsExtensionsIfPresent()
public void GetTestPlatformExtensionsShouldOnlyAddCoverletDataCollectorsExtensionsIfPresent()
{
this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny<string>())).Returns(true);
this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny<string>(), SearchOption.TopDirectoryOnly, It.IsAny<string[]>())).Returns(new[] { "foo.dll" });
var extensions = this.dotnetHostManager.GetTestPlatformExtensions(this.testSource, new List<string> { "abc.datacollector.dll" });
var extensions = this.dotnetHostManager.GetTestPlatformExtensions(this.testSource, new List<string> { "coverlet.collector.dll" });

Assert.AreEqual(1, extensions.Count());
}

[TestMethod]
public void GetTestPlatformExtensionsShouldNotAddNonCoverletDataCollectorsExtensionsIfPresent()
{
this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny<string>())).Returns(true);
this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny<string>(), SearchOption.TopDirectoryOnly, It.IsAny<string[]>())).Returns(new[] { "foo.dll" });
var extensions = this.dotnetHostManager.GetTestPlatformExtensions(this.testSource, new List<string> { "abc.dataollector.dll" });

Assert.AreEqual(0, extensions.Count());
}

[TestMethod]
public async Task LaunchTestHostShouldLaunchProcessWithConnectionInfo()
{
Expand Down

0 comments on commit fd77fc8

Please sign in to comment.