diff --git a/src/Adapter/MSTest.TestAdapter/Constants.cs b/src/Adapter/MSTest.TestAdapter/Constants.cs
index 569d49159b..7052dcda1a 100644
--- a/src/Adapter/MSTest.TestAdapter/Constants.cs
+++ b/src/Adapter/MSTest.TestAdapter/Constants.cs
@@ -70,8 +70,6 @@ internal static class Constants
internal static readonly TestProperty DeclaringClassNameProperty = TestProperty.Register("MSTestDiscoverer.DeclaringClassName", DeclaringClassNameLabel, typeof(string), TestPropertyAttributes.Hidden, typeof(TestCase));
- internal static readonly TestProperty AsyncTestProperty = TestProperty.Register("MSTestDiscoverer.IsAsync", IsAsyncLabel, typeof(bool), TestPropertyAttributes.Hidden, typeof(TestCase));
-
#pragma warning disable CS0618 // Type or member is obsolete
internal static readonly TestProperty TestCategoryProperty = TestProperty.Register("MSTestDiscoverer.TestCategory", TestCategoryLabel, typeof(string[]), TestPropertyAttributes.Hidden | TestPropertyAttributes.Trait, typeof(TestCase));
#pragma warning restore CS0618 // Type or member is obsolete
@@ -136,7 +134,6 @@ internal static class Constants
///
private const string TestClassNameLabel = "ClassName";
private const string DeclaringClassNameLabel = "DeclaringClassName";
- private const string IsAsyncLabel = "IsAsync";
private const string TestCategoryLabel = "TestCategory";
private const string PriorityLabel = "Priority";
private const string DeploymentItemsLabel = "DeploymentItems";
diff --git a/src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs b/src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs
index 74654b6bca..4b29e2414f 100644
--- a/src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs
+++ b/src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs
@@ -338,7 +338,7 @@ static string GetMethodName(MethodInfo methodInfo)
static UnitTestElement GetFixtureTest(string classFullName, string assemblyLocation, string fixtureType, string methodName, string[] hierarchy)
{
- var method = new TestMethod(classFullName, methodName, hierarchy, methodName, classFullName, assemblyLocation, false, null, TestIdGenerationStrategy.FullyQualified);
+ var method = new TestMethod(classFullName, methodName, hierarchy, methodName, classFullName, assemblyLocation, null, TestIdGenerationStrategy.FullyQualified);
return new UnitTestElement(method)
{
DisplayName = $"[{fixtureType}] {methodName}",
diff --git a/src/Adapter/MSTest.TestAdapter/Discovery/TypeEnumerator.cs b/src/Adapter/MSTest.TestAdapter/Discovery/TypeEnumerator.cs
index cbb50767f7..c2db89fa3d 100644
--- a/src/Adapter/MSTest.TestAdapter/Discovery/TypeEnumerator.cs
+++ b/src/Adapter/MSTest.TestAdapter/Discovery/TypeEnumerator.cs
@@ -129,12 +129,9 @@ internal UnitTestElement GetTestFromMethod(MethodInfo method, bool isDeclaredInT
// null if the current instance represents a generic type parameter.
DebugEx.Assert(_type.AssemblyQualifiedName != null, "AssemblyQualifiedName for method is null.");
- // This allows void returning async test method to be valid test method. Though they will be executed similar to non-async test method.
- bool isAsync = ReflectHelper.MatchReturnType(method, typeof(Task));
-
ManagedNameHelper.GetManagedName(method, out string managedType, out string managedMethod, out string?[]? hierarchyValues);
hierarchyValues[HierarchyConstants.Levels.ContainerIndex] = null; // This one will be set by test windows to current test project name.
- var testMethod = new TestMethod(managedType, managedMethod, hierarchyValues, method.Name, _type.FullName!, _assemblyFilePath, isAsync, null, _testIdGenerationStrategy);
+ var testMethod = new TestMethod(managedType, managedMethod, hierarchyValues, method.Name, _type.FullName!, _assemblyFilePath, null, _testIdGenerationStrategy);
if (!string.Equals(method.DeclaringType!.FullName, _type.FullName, StringComparison.Ordinal))
{
diff --git a/src/Adapter/MSTest.TestAdapter/Extensions/TestCaseExtensions.cs b/src/Adapter/MSTest.TestAdapter/Extensions/TestCaseExtensions.cs
index fafe4e6346..35f2d18207 100644
--- a/src/Adapter/MSTest.TestAdapter/Extensions/TestCaseExtensions.cs
+++ b/src/Adapter/MSTest.TestAdapter/Extensions/TestCaseExtensions.cs
@@ -69,7 +69,6 @@ internal static string GetTestName(this TestCase testCase, string? testClassName
/// The converted .
internal static UnitTestElement ToUnitTestElement(this TestCase testCase, string source)
{
- bool isAsync = (testCase.GetPropertyValue(Constants.AsyncTestProperty) as bool?) ?? false;
string? testClassName = testCase.GetPropertyValue(Constants.TestClassNameProperty) as string;
string name = testCase.GetTestName(testClassName);
var testIdGenerationStrategy = (TestIdGenerationStrategy)testCase.GetPropertyValue(
@@ -77,8 +76,8 @@ internal static UnitTestElement ToUnitTestElement(this TestCase testCase, string
(int)TestIdGenerationStrategy.FullyQualified);
TestMethod testMethod = testCase.ContainsManagedMethodAndType()
- ? new(testCase.GetManagedType(), testCase.GetManagedMethod(), testCase.GetHierarchy()!, name, testClassName!, source, isAsync, testCase.DisplayName, testIdGenerationStrategy)
- : new(name, testClassName!, source, isAsync, testCase.DisplayName, testIdGenerationStrategy);
+ ? new(testCase.GetManagedType(), testCase.GetManagedMethod(), testCase.GetHierarchy()!, name, testClassName!, source, testCase.DisplayName, testIdGenerationStrategy)
+ : new(name, testClassName!, source, testCase.DisplayName, testIdGenerationStrategy);
var dataType = (DynamicDataType)testCase.GetPropertyValue(Constants.TestDynamicDataTypeProperty, (int)DynamicDataType.None);
if (dataType != DynamicDataType.None)
{
@@ -96,7 +95,6 @@ internal static UnitTestElement ToUnitTestElement(this TestCase testCase, string
UnitTestElement testElement = new(testMethod)
{
- IsAsync = isAsync,
TestCategory = testCase.GetPropertyValue(Constants.TestCategoryProperty) as string[],
Priority = testCase.GetPropertyValue(Constants.PriorityProperty) as int?,
DisplayName = testCase.DisplayName,
diff --git a/src/Adapter/MSTest.TestAdapter/ObjectModel/TestMethod.cs b/src/Adapter/MSTest.TestAdapter/ObjectModel/TestMethod.cs
index 5b94d2bfa5..4b1c4f623f 100644
--- a/src/Adapter/MSTest.TestAdapter/ObjectModel/TestMethod.cs
+++ b/src/Adapter/MSTest.TestAdapter/ObjectModel/TestMethod.cs
@@ -34,19 +34,21 @@ public sealed class TestMethod : ITestMethod
private string? _declaringClassFullName;
private string? _declaringAssemblyName;
+#pragma warning disable IDE0060 // Remove unused parameter - Public API :/
public TestMethod(string name, string fullClassName, string assemblyName, bool isAsync)
- : this(null, null, null, name, fullClassName, assemblyName, isAsync, null, TestIdGenerationStrategy.FullyQualified)
+#pragma warning restore IDE0060 // Remove unused parameter
+ : this(null, null, null, name, fullClassName, assemblyName, null, TestIdGenerationStrategy.FullyQualified)
{
}
- internal TestMethod(string name, string fullClassName, string assemblyName, bool isAsync, string? displayName,
+ internal TestMethod(string name, string fullClassName, string assemblyName, string? displayName,
TestIdGenerationStrategy testIdGenerationStrategy)
- : this(null, null, null, name, fullClassName, assemblyName, isAsync, displayName, testIdGenerationStrategy)
+ : this(null, null, null, name, fullClassName, assemblyName, displayName, testIdGenerationStrategy)
{
}
internal TestMethod(string? managedTypeName, string? managedMethodName, string?[]? hierarchyValues, string name,
- string fullClassName, string assemblyName, bool isAsync, string? displayName,
+ string fullClassName, string assemblyName, string? displayName,
TestIdGenerationStrategy testIdGenerationStrategy)
{
Guard.NotNullOrWhiteSpace(assemblyName);
@@ -55,7 +57,6 @@ internal TestMethod(string? managedTypeName, string? managedMethodName, string?[
DisplayName = displayName ?? name;
FullClassName = fullClassName;
AssemblyName = assemblyName;
- IsAsync = isAsync;
if (hierarchyValues is null)
{
@@ -115,7 +116,7 @@ public string? DeclaringClassFullName
public string AssemblyName { get; private set; }
///
- public bool IsAsync { get; private set; }
+ public bool IsAsync => false; // TODO: Remove this property. We can't remove now as it's public and breaking change.
///
public string? ManagedTypeName { get; }
diff --git a/src/Adapter/MSTest.TestAdapter/ObjectModel/UnitTestElement.cs b/src/Adapter/MSTest.TestAdapter/ObjectModel/UnitTestElement.cs
index 1701b39c82..41fd283b8e 100644
--- a/src/Adapter/MSTest.TestAdapter/ObjectModel/UnitTestElement.cs
+++ b/src/Adapter/MSTest.TestAdapter/ObjectModel/UnitTestElement.cs
@@ -33,11 +33,6 @@ public UnitTestElement(TestMethod testMethod)
///
public TestMethod TestMethod { get; private set; }
- ///
- /// Gets or sets a value indicating whether it is a async test.
- ///
- public bool IsAsync { get; set; }
-
///
/// Gets or sets the test categories for test method.
///
@@ -144,12 +139,6 @@ internal TestCase ToTestCase()
testCase.SetPropertyValue(Constants.DeclaringClassNameProperty, TestMethod.DeclaringClassFullName);
}
- // Many of the tests will not be async, so there is no point in sending extra data
- if (IsAsync)
- {
- testCase.SetPropertyValue(Constants.AsyncTestProperty, IsAsync);
- }
-
// Set only if some test category is present
if (TestCategory is { Length: > 0 })
{
diff --git a/test/UnitTests/MSTestAdapter.UnitTests/Extensions/TestCaseExtensionsTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/Extensions/TestCaseExtensionsTests.cs
index 9e2843c535..85ce2aab59 100644
--- a/test/UnitTests/MSTestAdapter.UnitTests/Extensions/TestCaseExtensionsTests.cs
+++ b/test/UnitTests/MSTestAdapter.UnitTests/Extensions/TestCaseExtensionsTests.cs
@@ -20,20 +20,17 @@ public void ToUnitTestElementShouldReturnUnitTestElementWithFieldsSet()
};
string[] testCategories = ["DummyCategory"];
- testCase.SetPropertyValue(Constants.AsyncTestProperty, true);
testCase.SetPropertyValue(Constants.PriorityProperty, 2);
testCase.SetPropertyValue(Constants.TestCategoryProperty, testCategories);
testCase.SetPropertyValue(Constants.TestClassNameProperty, "DummyClassName");
var resultUnitTestElement = testCase.ToUnitTestElement(testCase.Source);
- Verify(resultUnitTestElement.IsAsync);
Verify(resultUnitTestElement.Priority == 2);
Verify(testCategories == resultUnitTestElement.TestCategory);
Verify(resultUnitTestElement.DisplayName == "DummyDisplayName");
Verify(resultUnitTestElement.TestMethod.Name == "DummyMethod");
Verify(resultUnitTestElement.TestMethod.FullClassName == "DummyClassName");
- Verify(resultUnitTestElement.TestMethod.IsAsync);
Verify(resultUnitTestElement.TestMethod.DeclaringClassFullName is null);
}
@@ -45,7 +42,6 @@ public void ToUnitTestElementForTestCaseWithNoPropertiesShouldReturnUnitTestElem
var resultUnitTestElement = testCase.ToUnitTestElement(testCase.Source);
// These are set for testCase by default by ObjectModel.
- Verify(!resultUnitTestElement.IsAsync);
Verify(resultUnitTestElement.Priority == 0);
Verify(resultUnitTestElement.TestCategory is null);
}
diff --git a/test/UnitTests/MSTestAdapter.UnitTests/ObjectModel/UnitTestElementTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/ObjectModel/UnitTestElementTests.cs
index 2d99951a67..ee73e41096 100644
--- a/test/UnitTests/MSTestAdapter.UnitTests/ObjectModel/UnitTestElementTests.cs
+++ b/test/UnitTests/MSTestAdapter.UnitTests/ObjectModel/UnitTestElementTests.cs
@@ -87,19 +87,6 @@ public void ToTestCaseShouldSetDeclaringClassNameIfPresent()
Verify((testCase.GetPropertyValue(Constants.DeclaringClassNameProperty) as string) == "DC");
}
- public void ToTestCaseShouldSetIsAsyncProperty()
- {
- _unitTestElement.IsAsync = true;
- var testCase = _unitTestElement.ToTestCase();
-
- Verify((bool)testCase.GetPropertyValue(Constants.AsyncTestProperty));
-
- _unitTestElement.IsAsync = false;
- testCase = _unitTestElement.ToTestCase();
-
- Verify(!(bool)testCase.GetPropertyValue(Constants.AsyncTestProperty));
- }
-
public void ToTestCaseShouldSetTestCategoryIfPresent()
{
_unitTestElement.TestCategory = null;
@@ -188,7 +175,7 @@ public void ToTestCase_WhenStrategyIsLegacy_UsesDefaultTestCaseId()
#pragma warning disable CA2263 // Prefer generic overload when type is known
foreach (DynamicDataType dataType in Enum.GetValues(typeof(DynamicDataType)))
{
- var testCase = new UnitTestElement(new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, TestIdGenerationStrategy.Legacy) { DataType = dataType }).ToTestCase();
+ var testCase = new UnitTestElement(new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, TestIdGenerationStrategy.Legacy) { DataType = dataType }).ToTestCase();
var expectedTestCase = new TestCase(testCase.FullyQualifiedName, testCase.ExecutorUri, testCase.Source);
Verify(expectedTestCase.Id == testCase.Id);
Verify(testCase.GetPropertyValue(Constants.TestIdGenerationStrategyProperty).Equals((int)TestIdGenerationStrategy.Legacy));
@@ -202,7 +189,7 @@ public void ToTestCase_WhenStrategyIsDisplayName_DoesNotUseDefaultTestCaseId()
#pragma warning disable CA2263 // Prefer generic overload when type is known
foreach (DynamicDataType dataType in Enum.GetValues(typeof(DynamicDataType)))
{
- var testCase = new UnitTestElement(new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, TestIdGenerationStrategy.DisplayName) { DataType = dataType }).ToTestCase();
+ var testCase = new UnitTestElement(new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, TestIdGenerationStrategy.DisplayName) { DataType = dataType }).ToTestCase();
var expectedTestCase = new TestCase(testCase.FullyQualifiedName, testCase.ExecutorUri, testCase.Source);
if (dataType == DynamicDataType.None)
{
@@ -223,7 +210,7 @@ public void ToTestCase_WhenStrategyIsData_DoesNotUseDefaultTestCaseId()
#pragma warning disable CA2263 // Prefer generic overload when type is known
foreach (DynamicDataType dataType in Enum.GetValues(typeof(DynamicDataType)))
{
- var testCase = new UnitTestElement(new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, TestIdGenerationStrategy.FullyQualified) { DataType = dataType }).ToTestCase();
+ var testCase = new UnitTestElement(new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, TestIdGenerationStrategy.FullyQualified) { DataType = dataType }).ToTestCase();
var expectedTestCase = new TestCase(testCase.FullyQualifiedName, testCase.ExecutorUri, testCase.Source);
Verify(expectedTestCase.Id != testCase.Id);
Verify(testCase.GetPropertyValue(Constants.TestIdGenerationStrategyProperty).Equals((int)TestIdGenerationStrategy.FullyQualified));
@@ -238,19 +225,19 @@ public void ToTestCase_WhenStrategyIsDisplayName_ExamplesOfTestCaseIdUniqueness(
TestCase[] testCases =
[
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy))
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy))
.ToTestCase(),
new UnitTestElement(
- new("MyOtherMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy))
+ new("MyOtherMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy))
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyOtherProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy))
+ new("MyMethod", "MyOtherProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy))
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyOtherAssembly", false, null, testIdStrategy))
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyOtherAssembly", null, testIdStrategy))
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy)
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy)
{
DataType = DynamicDataType.DataSourceAttribute,
})
@@ -259,7 +246,7 @@ public void ToTestCase_WhenStrategyIsDisplayName_ExamplesOfTestCaseIdUniqueness(
}
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy)
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy)
{
DataType = DynamicDataType.ITestDataSource,
})
@@ -279,34 +266,34 @@ public void ToTestCase_WhenStrategyIsDisplayName_ExamplesOfTestCaseIdCollision()
TestCase[] testCases =
[
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy)
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy)
{
DataType = DynamicDataType.DataSourceAttribute,
})
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy)
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy)
{
DataType = DynamicDataType.DataSourceAttribute,
SerializedData = ["1"],
})
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy)
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy)
{
DataType = DynamicDataType.DataSourceAttribute,
SerializedData = ["2"],
})
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy)
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy)
{
DataType = DynamicDataType.ITestDataSource,
SerializedData = ["1"],
})
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy)
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy)
{
DataType = DynamicDataType.ITestDataSource,
SerializedData = ["2"],
@@ -323,31 +310,31 @@ public void ToTestCase_WhenStrategyIsFullyQualifiedTest_ExamplesOfTestCaseIdUniq
TestCase[] testCases =
[
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy))
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy))
.ToTestCase(),
new UnitTestElement(
- new("MyOtherMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy))
+ new("MyOtherMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy))
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyOtherProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy))
+ new("MyMethod", "MyOtherProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy))
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyOtherAssembly", false, null, testIdStrategy))
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyOtherAssembly", null, testIdStrategy))
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy)
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy)
{
SerializedData = ["System.Int32[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "[]"],
})
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy)
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy)
{
SerializedData = ["System.Int32[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "[1]"],
})
.ToTestCase(),
new UnitTestElement(
- new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", false, null, testIdStrategy)
+ new("MyMethod", "MyProduct.MyNamespace.MyClass", "MyAssembly", null, testIdStrategy)
{
SerializedData = ["System.Int32[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "[1,1]"],
})