diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestDiscoveryExtensionManager.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestDiscoveryExtensionManager.cs
index 727ed5dab2..e5fa418ea9 100644
--- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestDiscoveryExtensionManager.cs
+++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestDiscoveryExtensionManager.cs
@@ -8,6 +8,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework
using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities;
using Microsoft.VisualStudio.TestPlatform.Common.Interfaces;
+ using Microsoft.VisualStudio.TestPlatform.Common.Utilities;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
@@ -169,7 +170,7 @@ internal class TestDiscovererMetadata : ITestDiscovererCapabilities
///
/// The file Extensions.
/// The default Executor Uri.
- public TestDiscovererMetadata(IReadOnlyCollection fileExtensions, string defaultExecutorUri)
+ public TestDiscovererMetadata(IReadOnlyCollection fileExtensions, string defaultExecutorUri, AssemblyType assemblyType = default(AssemblyType))
{
if (fileExtensions != null && fileExtensions.Count > 0)
{
@@ -180,6 +181,8 @@ public TestDiscovererMetadata(IReadOnlyCollection fileExtensions, string
{
this.DefaultExecutorUri = new Uri(defaultExecutorUri);
}
+
+ this.AssemblyType = assemblyType;
}
///
@@ -199,5 +202,14 @@ public Uri DefaultExecutorUri
get;
private set;
}
+
+ ///
+ /// Gets assembly type supported by the discoverer.
+ ///
+ public AssemblyType AssemblyType
+ {
+ get;
+ private set;
+ }
}
}
diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs
index c1d78f3e97..60209d116f 100644
--- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs
+++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs
@@ -5,9 +5,11 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilitie
{
using System;
using System.Collections.Generic;
+ using System.ComponentModel;
using System.Linq;
using System.Reflection;
+ using Microsoft.VisualStudio.TestPlatform.Common.Utilities;
using ObjectModel;
///
@@ -26,6 +28,7 @@ public TestDiscovererPluginInformation(Type testDiscovererType)
{
this.FileExtensions = GetFileExtensions(testDiscovererType);
this.DefaultExecutorUri = GetDefaultExecutorUri(testDiscovererType);
+ this.AssemblyType = GetAssemblyType(testDiscovererType);
}
}
@@ -36,7 +39,7 @@ public override ICollection
Uri DefaultExecutorUri { get; }
+
+ ///
+ /// Assembly type that the test discoverer supports.
+ ///
+ AssemblyType AssemblyType { get; }
}
}
diff --git a/src/Microsoft.TestPlatform.Common/Utilities/AssemblyType.cs b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyType.cs
new file mode 100644
index 0000000000..045c6177bb
--- /dev/null
+++ b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyType.cs
@@ -0,0 +1,12 @@
+// 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.Utilities
+{
+ public enum AssemblyType
+ {
+ None,
+ Native,
+ Managed
+ }
+}
diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs
index e78abff7e3..b7495ad485 100644
--- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs
+++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs
@@ -8,6 +8,7 @@ namespace TestPlatform.Common.UnitTests.ExtensionFramework
using System.Reflection;
using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework;
+ using Microsoft.VisualStudio.TestPlatform.Common.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
@@ -124,5 +125,13 @@ public void TestDiscovererMetadataCtorSetsDefaultUri()
Assert.AreEqual("executor://helloworld/", metadata.DefaultExecutorUri.AbsoluteUri);
}
+
+ [TestMethod]
+ public void TestDiscovererMetadataCtorSetsAssemblyType()
+ {
+ var metadata = new TestDiscovererMetadata(null, "executor://helloworld", AssemblyType.Native);
+
+ Assert.AreEqual(AssemblyType.Native, metadata.AssemblyType);
+ }
}
}
diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/LazyExtensionTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/LazyExtensionTests.cs
index b493ac1b79..e4a3dc41a7 100644
--- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/LazyExtensionTests.cs
+++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/LazyExtensionTests.cs
@@ -4,16 +4,18 @@
namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities
{
using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
using System.Linq;
using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities;
+ using Microsoft.VisualStudio.TestPlatform.Common.Interfaces;
+ using Microsoft.VisualStudio.TestPlatform.Common.Utilities;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
- using Microsoft.VisualStudio.TestPlatform.Common.Interfaces;
- using Moq;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
- using System.Collections.Generic;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+ using Moq;
[TestClass]
public class LazyExtensionTests
@@ -96,6 +98,7 @@ public void MetadataShouldCreateMetadataFromMetadataType()
Assert.AreEqual(typeof(DummyDiscovererCapability), metadata.GetType());
CollectionAssert.AreEqual(new List { "csv" }, (metadata as ITestDiscovererCapabilities).FileExtension.ToArray());
Assert.AreEqual("executor://unittestexecutor/", (metadata as ITestDiscovererCapabilities).DefaultExecutorUri.AbsoluteUri);
+ Assert.AreEqual(AssemblyType.Native, (metadata as ITestDiscovererCapabilities).AssemblyType);
}
#endregion
@@ -116,16 +119,24 @@ public Uri DefaultExecutorUri
private set;
}
- public DummyDiscovererCapability(List fileExtensions, string executorURI)
+ public AssemblyType AssemblyType
+ {
+ get;
+ private set;
+ }
+
+ public DummyDiscovererCapability(List fileExtensions, string executorURI, AssemblyType assemblyType)
{
this.FileExtension = fileExtensions;
this.DefaultExecutorUri = new Uri(executorURI);
+ this.AssemblyType = assemblyType;
}
}
[FileExtension("csv")]
[DefaultExecutorUri("executor://unittestexecutor")]
+ [Category("native")]
private class DummyExtension : ITestDiscoverer
{
public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestDiscovererPluginInformationTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestDiscovererPluginInformationTests.cs
index de7e59bce6..1895ca3d4c 100644
--- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestDiscovererPluginInformationTests.cs
+++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestDiscovererPluginInformationTests.cs
@@ -4,13 +4,15 @@
namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities
{
using System;
- using System.Linq;
using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Linq;
using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
+ using Microsoft.VisualStudio.TestPlatform.Common.Utilities;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
-
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
[TestClass]
public class TestDiscovererPluginInformationTests
{
@@ -52,6 +54,55 @@ public void FileExtensionsShouldReturnSupportedFileExtensionsForADiscoverer()
CollectionAssert.AreEqual(new List {"csv", "docx"}, this.testPluginInformation.FileExtensions);
}
+ [TestMethod]
+ public void AssemblyTypeShouldReturnNoneIfDiscovererHasNoCategory()
+ {
+ this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithNoCategory));
+ Assert.AreEqual(AssemblyType.None, this.testPluginInformation.AssemblyType);
+ }
+
+ [TestMethod]
+ public void AssemblyTypeShouldReturnNoneIfDiscovererHasCategoryWithNoValue()
+ {
+ this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithCategoryHavingNoValue));
+ Assert.AreEqual(AssemblyType.None, this.testPluginInformation.AssemblyType);
+ }
+
+ [TestMethod]
+ public void AssemblyTypeShouldReturnNoneIfDiscovererHasCategoryWithEmptyValue()
+ {
+ this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithCategoryHavingEmptyValue));
+ Assert.AreEqual(AssemblyType.None, this.testPluginInformation.AssemblyType);
+ }
+
+ [TestMethod]
+ public void AssemblyTypeShouldReturnNativeIfDiscovererHasNativeCategory()
+ {
+ this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithNativeCategory));
+ Assert.AreEqual(AssemblyType.Native, this.testPluginInformation.AssemblyType);
+ }
+
+ [TestMethod]
+ public void AssemblyTypeShouldReturnManagedIfDiscovererHasManagedCategory()
+ {
+ this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithManagedCategory));
+ Assert.AreEqual(AssemblyType.Managed, this.testPluginInformation.AssemblyType);
+ }
+
+ [TestMethod]
+ public void AssemblyTypeShouldReturnNoneIfDiscovererHasUnknownCategory()
+ {
+ this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithUnknownCategory));
+ Assert.AreEqual(AssemblyType.None, this.testPluginInformation.AssemblyType);
+ }
+
+ [TestMethod]
+ public void AssemblyTypeShouldReturnAssemblyTypeIfDiscovererHasCategoryInArbitCasing()
+ {
+ this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithArbitCasedCategory));
+ Assert.AreEqual(AssemblyType.Native, this.testPluginInformation.AssemblyType);
+ }
+
[TestMethod]
public void DefaultExecutorUriShouldReturnEmptyListIfADiscovererDoesNotHaveOne()
{
@@ -68,7 +119,7 @@ public void DefaultExecutorUriShouldReturnDefaultExecutorUriOfADiscoverer()
}
[TestMethod]
- public void MetadataShouldReturnFileExtensionsAndDefaultExecutorUri()
+ public void MetadataShouldReturnFileExtensionsAndDefaultExecutorUriAndAssemblyType()
{
this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithTwoFileExtensions));
@@ -77,6 +128,7 @@ public void MetadataShouldReturnFileExtensionsAndDefaultExecutorUri()
CollectionAssert.AreEqual(expectedFileExtensions, (testPluginMetada[0] as List).ToArray());
Assert.AreEqual("csvexecutor", testPluginMetada[1] as string);
+ Assert.AreEqual(AssemblyType.Managed, Enum.Parse(typeof(AssemblyType), testPluginMetada[2].ToString()));
}
}
@@ -86,6 +138,47 @@ public class DummyTestDiscovererWithNoFileExtensions
{
}
+ [FileExtension(".dll")]
+ public class DummyTestDiscovereWithNoCategory
+ {
+ }
+
+ [FileExtension(".dll")]
+ [Category]
+ public class DummyTestDiscovereWithCategoryHavingNoValue
+ {
+ }
+
+ [FileExtension(".dll")]
+ [Category]
+ public class DummyTestDiscovereWithCategoryHavingEmptyValue
+ {
+ }
+
+ [FileExtension(".js")]
+ [Category("native")]
+ public class DummyTestDiscovereWithNativeCategory
+ {
+ }
+
+ [FileExtension(".dll")]
+ [Category("managed")]
+ public class DummyTestDiscovereWithManagedCategory
+ {
+ }
+
+ [FileExtension(".dll")]
+ [Category("arbitValue")]
+ public class DummyTestDiscovereWithUnknownCategory
+ {
+ }
+
+ [FileExtension(".dll")]
+ [Category("NatIVe")]
+ public class DummyTestDiscovereWithArbitCasedCategory
+ {
+ }
+
[FileExtension("csv")]
[DefaultExecutorUri("csvexecutor")]
public class DummyTestDiscovererWithOneFileExtensions
@@ -94,6 +187,7 @@ public class DummyTestDiscovererWithOneFileExtensions
[FileExtension("csv")]
[FileExtension("docx")]
+ [Category("managed")]
[DefaultExecutorUri("csvexecutor")]
public class DummyTestDiscovererWithTwoFileExtensions
{