From a2972a03602524d73b2ad9805a274e4f721cdb2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Mon, 26 Aug 2024 15:03:53 +0200 Subject: [PATCH] Update test project to use MSTest --- .../MSTest.IntegrationTests/ClsTests.cs | 5 ++++- .../DiscoverInternalsTests.cs | 5 +++++ .../FSharpTestProjectTests.cs | 3 +++ .../MSTest.IntegrationTests.csproj | 15 ++++++++++++- .../MSTest.IntegrationTests.testconfig.json | 8 +++++++ .../NoNamespaceTests.cs | 3 +++ .../MSTest.IntegrationTests/OutputTests.cs | 5 +++++ .../DataExtensibilityTests.cs | 6 +++++ .../Parameterized tests/DataRowTests.cs | 16 ++++++++++++++ .../Parameterized tests/DataSourceTests.cs | 2 ++ .../Parameterized tests/DynamicDataTests.cs | 4 ++++ .../MSTest.IntegrationTests/Program.cs | 22 +++++++++++++++++++ .../TestId.DefaultStrategy.cs | 9 ++++++++ .../TestId.DisplayNameStrategy.cs | 8 +++++++ .../TestId.FullyQualifiedStrategy.cs | 9 ++++++++ .../TestId.LegacyStrategy.cs | 10 +++++++++ .../Utilities/CLITestBase.discovery.cs | 4 +--- .../Automation.CLI/CLITestBase.common.cs | 4 +--- 18 files changed, 130 insertions(+), 8 deletions(-) create mode 100644 test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.testconfig.json create mode 100644 test/IntegrationTests/MSTest.IntegrationTests/Program.cs diff --git a/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs index 042cf09853..3e4c47851c 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs @@ -2,15 +2,18 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.MSTestV2.CLIAutomation; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; +[TestClass] public class ClsTests : CLITestBase { private const string TestAssetName = "ClsTestProject"; // This test in itself is not so important. What matters is that the asset gets build. If we regress and start having - // the [DataRow] attribute no longer CLS compliant, the build will raise a warning in VS (and the build will fail in CI). + // the [DataRow] attribute no longer CLS compliant, the build will raise a warning in VS (and the build will fail in CI.) + [TestMethod] public void TestsAreRun() { // Arrange diff --git a/test/IntegrationTests/MSTest.IntegrationTests/DiscoverInternalsTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/DiscoverInternalsTests.cs index f26866c86e..c01acabe40 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/DiscoverInternalsTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/DiscoverInternalsTests.cs @@ -2,13 +2,16 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.MSTestV2.CLIAutomation; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; +[TestClass] public class DiscoverInternalsTests : CLITestBase { private const string TestAsset = "DiscoverInternalsProject"; + [TestMethod] public void InternalTestClassesAreDiscoveredWhenTheDiscoverInternalsAttributeIsPresent() { // Arrange @@ -25,6 +28,7 @@ public void InternalTestClassesAreDiscoveredWhenTheDiscoverInternalsAttributeIsP "NestedInternalClass_TestMethod1"); } + [TestMethod] public void AnInternalTestClassDerivedFromAPublicAbstractGenericBaseClassForAnInternalTypeIsDiscovered() { // Arrange @@ -39,6 +43,7 @@ public void AnInternalTestClassDerivedFromAPublicAbstractGenericBaseClassForAnIn "EqualityIsCaseInsensitive"); } + [TestMethod] public void AnInternalTypeCanBeUsedInADynamicDataTestMethod() { string assemblyPath = Path.IsPathRooted(TestAsset) ? TestAsset : GetAssetFullPath(TestAsset); diff --git a/test/IntegrationTests/MSTest.IntegrationTests/FSharpTestProjectTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/FSharpTestProjectTests.cs index f26c80e6f4..2aa659ab97 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/FSharpTestProjectTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/FSharpTestProjectTests.cs @@ -2,13 +2,16 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.MSTestV2.CLIAutomation; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; +[TestClass] public class FSharpTestProjectTests : CLITestBase { private const string TestAssetName = "FSharpTestProject"; + [TestMethod] public void TestFSharpTestsWithSpaceAndDotInName() { // Arrange diff --git a/test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csproj b/test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csproj index f3d07dbd58..f9149ca0d4 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csproj +++ b/test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csproj @@ -4,6 +4,8 @@ $(NetFrameworkMinimum) false $(NoWarn),1685 + Exe + false @@ -17,8 +19,19 @@ - + + + + + + + + + + + PreserveNewest + diff --git a/test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.testconfig.json b/test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.testconfig.json new file mode 100644 index 0000000000..bb8420ddd5 --- /dev/null +++ b/test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.testconfig.json @@ -0,0 +1,8 @@ +{ + "platformOptions": { + "telemetry": { + "isDevelopmentRepository": true + }, + "exitProcessOnUnhandledException": false + } +} diff --git a/test/IntegrationTests/MSTest.IntegrationTests/NoNamespaceTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/NoNamespaceTests.cs index 6d192ba954..61f26b85cc 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/NoNamespaceTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/NoNamespaceTests.cs @@ -7,13 +7,16 @@ using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Extensions; using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; +[TestClass] public class NoNamespaceTests : CLITestBase { private const string TestAssetName = "HierarchyProject"; + [TestMethod] public void TestsAreDiscoveredWithExpectedHierarchy() { // Arrange & Act diff --git a/test/IntegrationTests/MSTest.IntegrationTests/OutputTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/OutputTests.cs index fcb07b4ed8..b21dc6baca 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/OutputTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/OutputTests.cs @@ -7,6 +7,9 @@ using Microsoft.MSTestV2.CLIAutomation; using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using TestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult; namespace MSTest.IntegrationTests; @@ -14,8 +17,10 @@ public class OutputTests : CLITestBase { private const string TestAssetName = "OutputTestProject"; + [TestMethod] public void OutputIsNotMixedWhenTestsRunInParallel() => ValidateOutputForClass("UnitTest1"); + [TestMethod] public void OutputIsNotMixedWhenAsyncTestsRunInParallel() => ValidateOutputForClass("UnitTest2"); private void ValidateOutputForClass(string className) diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs index e36a2f78ef..7d558adaf9 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs @@ -2,9 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.MSTestV2.CLIAutomation; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; +[TestClass] public class DataExtensibilityTests : CLITestBase { private const string TestAssetName = "FxExtensibilityTestProject"; @@ -15,6 +17,7 @@ public class DataExtensibilityTests : CLITestBase - Ignored tests are not expanded (DataRow, DataSource, etc) */ + [TestMethod] public void CustomTestDataSourceTests() { // Arrange @@ -28,6 +31,7 @@ public void CustomTestDataSourceTests() VerifyE2E.ContainsTestsPassed(testResults, "CustomTestDataSourceTestMethod1 (1,2,3)", "CustomTestDataSourceTestMethod1 (4,5,6)"); } + [TestMethod] public void AssertExtensibilityTests() { // Arrange @@ -42,6 +46,7 @@ public void AssertExtensibilityTests() VerifyE2E.ContainsTestsFailed(testResults, "BasicFailingAssertExtensionTest", "ChainedFailingAssertExtensionTest"); } + [TestMethod] public void ExecuteCustomTestExtensibilityTests() { // Arrange @@ -69,6 +74,7 @@ public void ExecuteCustomTestExtensibilityTests() "CustomTestClass1 - Execution number 3"); } + [TestMethod] public void ExecuteCustomTestExtensibilityWithTestDataTests() { // Arrange diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs index 4be71e0050..f4cd83e671 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -2,13 +2,16 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.MSTestV2.CLIAutomation; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; +[TestClass] public class DataRowTests : CLITestBase { private const string TestAssetName = "DataRowTestProject"; + [TestMethod] public void ExecuteOnlyDerivedClassDataRowsWhenBothBaseAndDerivedClassHasDataRows_SimpleDataRows() { // Arrange @@ -28,6 +31,7 @@ public void ExecuteOnlyDerivedClassDataRowsWhenBothBaseAndDerivedClassHasDataRow "DataRowTestMethod (\"DerivedString2\")"); } + [TestMethod] public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_SimpleDataRows() { // Arrange @@ -44,6 +48,7 @@ public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_Simp "DataRowTestMethod (\"DerivedString2\")"); } + [TestMethod] public void DataRowsExecuteWithRequiredAndOptionalParameters() { // Arrange @@ -61,6 +66,7 @@ public void DataRowsExecuteWithRequiredAndOptionalParameters() "DataRowTestMethodWithSomeOptionalParameters (123,\"DerivedOptionalString2\",\"DerivedOptionalString3\")"); } + [TestMethod] public void DataRowsExecuteWithParamsArrayParameter() { // Arrange @@ -79,6 +85,7 @@ public void DataRowsExecuteWithParamsArrayParameter() "DataRowTestMethodWithParamsParameters (2,\"DerivedParamsArg1\",\"DerivedParamsArg2\",\"DerivedParamsArg3\")"); } + [TestMethod] public void DataRowsFailWhenInvalidArgumentsProvided() { // Arrange @@ -96,6 +103,7 @@ public void DataRowsFailWhenInvalidArgumentsProvided() "DataRowTestMethodFailsWithInvalidArguments (2,\"DerivedRequiredArgument\",\"DerivedOptionalArgument\",\"DerivedExtraArgument\")"); } + [TestMethod] public void DataRowsShouldSerializeDoublesProperly() { // Arrange @@ -112,6 +120,7 @@ public void DataRowsShouldSerializeDoublesProperly() "DataRowTestDouble (10.02,20.02)"); } + [TestMethod] public void DataRowsShouldSerializeMixedTypesProperly() { // Arrange @@ -127,6 +136,7 @@ public void DataRowsShouldSerializeMixedTypesProperly() "DataRowTestMixed (10,10,10,10,10,10,10,\"10\")"); } + [TestMethod] public void DataRowsShouldSerializeEnumsProperly() { // Arrange @@ -145,6 +155,7 @@ public void DataRowsShouldSerializeEnumsProperly() "DataRowEnums (Gamma)"); } + [TestMethod] public void DataRowsShouldHandleNonSerializableValues() { // Arrange @@ -166,6 +177,7 @@ public void DataRowsShouldHandleNonSerializableValues() "DataRowNonSerializable (DataRowTestProject.DataRowTests_DerivedClass)"); } + [TestMethod] public void ExecuteDataRowTests_Enums() { // Arrange @@ -241,6 +253,7 @@ public void ExecuteDataRowTests_Enums() VerifyE2E.FailedTestCount(testResults, 0); } + [TestMethod] public void ExecuteDataRowTests_NonSerializablePaths() { // Arrange @@ -259,6 +272,7 @@ public void ExecuteDataRowTests_NonSerializablePaths() VerifyE2E.FailedTestCount(testResults, 0); } + [TestMethod] public void ExecuteDataRowTests_Regular() { // Arrange @@ -320,6 +334,7 @@ public void ExecuteDataRowTests_Regular() "DataRowTestMethodFailsWithInvalidArguments (2,\"DerivedRequiredArgument\",\"DerivedOptionalArgument\",\"DerivedExtraArgument\")"); } + [TestMethod] public void GetDisplayName_AfterOverriding_GetsTheNewDisplayName() { // Arrange @@ -334,6 +349,7 @@ public void GetDisplayName_AfterOverriding_GetsTheNewDisplayName() "Overridden DisplayName"); } + [TestMethod] public void ParameterizedTestsWithTestMethodSettingDisplayName_DataIsPrefixWithDisplayName() { // Arrange diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataSourceTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataSourceTests.cs index cedbf48a14..8366d21ad5 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataSourceTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataSourceTests.cs @@ -2,9 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.MSTestV2.CLIAutomation; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; +[TestClass] public class DataSourceTests : CLITestBase { private const string TestAssetName = "DataSourceTestProject"; diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DynamicDataTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DynamicDataTests.cs index 952119a8bb..669d7e6b73 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DynamicDataTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DynamicDataTests.cs @@ -2,13 +2,16 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.MSTestV2.CLIAutomation; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; +[TestClass] public class DynamicDataTests : CLITestBase { private const string TestAssetName = "DynamicDataTestProject"; + [TestMethod] public void ExecuteDynamicDataTests() { // Arrange @@ -56,6 +59,7 @@ public void ExecuteDynamicDataTests() VerifyE2E.FailedTestCount(testResults, 0); } + [TestMethod] public void ExecuteDynamicDataTestsWithCategoryFilter() { // Arrange diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Program.cs b/test/IntegrationTests/MSTest.IntegrationTests/Program.cs new file mode 100644 index 0000000000..d6fcbb2dc7 --- /dev/null +++ b/test/IntegrationTests/MSTest.IntegrationTests/Program.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Reflection; + +using Microsoft.Testing.Platform.Builder; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)] + +// To attach to the children +// Microsoft.Testing.TestInfrastructure.DebuggerUtility.AttachCurrentProcessToParentVSProcess(); +ITestApplicationBuilder testApplicationBuilder = await TestApplication.CreateBuilderAsync(args); +testApplicationBuilder.AddMSTest(() => [Assembly.GetEntryAssembly()!]); + +// Enable Trx +// testApplicationBuilder.AddTrxReportProvider(); + +// Enable Telemetry +// testApplicationBuilder.AddAppInsightsTelemetryProvider(); +using ITestApplication testApplication = await testApplicationBuilder.BuildAsync(); +return await testApplication.RunAsync(); diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs index 924ac62427..f3fa72ee1b 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs @@ -4,6 +4,7 @@ using FluentAssertions; using Microsoft.MSTestV2.CLIAutomation; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; @@ -11,6 +12,7 @@ public partial class TestId : CLITestBase { private const string DefaultStrategyDll = "TestIdProject.DefaultStrategy"; + [TestMethod] public void TestIdUniqueness_DataRowArray_DefaultStrategy() { // Arrange @@ -32,6 +34,7 @@ public void TestIdUniqueness_DataRowArray_DefaultStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_DataRowString_DefaultStrategy() { // Arrange @@ -54,6 +57,7 @@ public void TestIdUniqueness_DataRowString_DefaultStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_DynamicDataArrays_DefaultStrategy() { // Arrange @@ -75,6 +79,7 @@ public void TestIdUniqueness_DynamicDataArrays_DefaultStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_DynamicDataTuple_DefaultStrategy() { // Arrange @@ -95,6 +100,7 @@ public void TestIdUniqueness_DynamicDataTuple_DefaultStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_DynamicDataGenericCollections_DefaultStrategy() { // Arrange @@ -117,6 +123,7 @@ public void TestIdUniqueness_DynamicDataGenericCollections_DefaultStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceArrays_DefaultStrategy() { // Arrange @@ -138,6 +145,7 @@ public void TestIdUniqueness_TestDataSourceArrays_DefaultStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceTuples_DefaultStrategy() { // Arrange @@ -158,6 +166,7 @@ public void TestIdUniqueness_TestDataSourceTuples_DefaultStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceGenericCollections_DefaultStrategy() { // Arrange diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs index 503fa65dfc..8e96fd423b 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs @@ -4,6 +4,7 @@ using FluentAssertions; using Microsoft.MSTestV2.CLIAutomation; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; @@ -11,6 +12,7 @@ public partial class TestId : CLITestBase { private const string DisplayNameStrategyDll = "TestIdProject.DisplayNameStrategy"; + [TestMethod] public void TestIdUniqueness_DataRowArray_DisplayNameStrategy() { // Arrange @@ -32,6 +34,7 @@ public void TestIdUniqueness_DataRowArray_DisplayNameStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } + [TestMethod] public void TestIdUniqueness_DataRowString_DisplayNameStrategy() { // Arrange @@ -55,6 +58,7 @@ public void TestIdUniqueness_DataRowString_DisplayNameStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().HaveCount(3); } + [TestMethod] public void TestIdUniqueness_DynamicDataArrays_DisplayNameStrategy() { // Arrange @@ -96,6 +100,7 @@ public void TestIdUniqueness_DynamicDataTuple_DisplayNameStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_DynamicDataGenericCollections_DisplayNameStrategy() { // Arrange @@ -118,6 +123,7 @@ public void TestIdUniqueness_DynamicDataGenericCollections_DisplayNameStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceArrays_DisplayNameStrategy() { // Arrange @@ -139,6 +145,7 @@ public void TestIdUniqueness_TestDataSourceArrays_DisplayNameStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceTuples_DisplayNameStrategy() { // Arrange @@ -159,6 +166,7 @@ public void TestIdUniqueness_TestDataSourceTuples_DisplayNameStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceGenericCollections_DisplayNameStrategy() { // Arrange diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs index 4842ea364d..aa4110fb08 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs @@ -6,6 +6,7 @@ using FluentAssertions; using Microsoft.MSTestV2.CLIAutomation; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; @@ -13,6 +14,7 @@ public partial class TestId : CLITestBase { private const string FullyQualifiedStrategyDll = "TestIdProject.FullyQualifiedStrategy"; + [TestMethod] public void TestIdUniqueness_DataRowArray_FullyQualifiedStrategy() { // Arrange @@ -34,6 +36,7 @@ public void TestIdUniqueness_DataRowArray_FullyQualifiedStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_DataRowString_FullyQualifiedStrategy() { // Arrange @@ -56,6 +59,7 @@ public void TestIdUniqueness_DataRowString_FullyQualifiedStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_DynamicDataArrays_FullyQualifiedStrategy() { // Arrange @@ -77,6 +81,7 @@ public void TestIdUniqueness_DynamicDataArrays_FullyQualifiedStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_DynamicDataTuple_FullyQualifiedStrategy() { // Arrange @@ -97,6 +102,7 @@ public void TestIdUniqueness_DynamicDataTuple_FullyQualifiedStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_DynamicDataGenericCollections_FullyQualifiedStrategy() { // Arrange @@ -119,6 +125,7 @@ public void TestIdUniqueness_DynamicDataGenericCollections_FullyQualifiedStrateg testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceArrays_FullyQualifiedStrategy() { // Arrange @@ -140,6 +147,7 @@ public void TestIdUniqueness_TestDataSourceArrays_FullyQualifiedStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceTuples_FullyQualifiedStrategy() { // Arrange @@ -160,6 +168,7 @@ public void TestIdUniqueness_TestDataSourceTuples_FullyQualifiedStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceGenericCollections_FullyQualifiedStrategy() { // Arrange diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs index 4f53cbfdd3..4fe49fa443 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs @@ -4,13 +4,16 @@ using FluentAssertions; using Microsoft.MSTestV2.CLIAutomation; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MSTest.IntegrationTests; +[TestClass] public partial class TestId : CLITestBase { private const string LegacyStrategyDll = "TestIdProject.LegacyStrategy"; + [TestMethod] public void TestIdUniqueness_DataRowArray_LegacyStrategy() { // Arrange @@ -33,6 +36,7 @@ public void TestIdUniqueness_DataRowArray_LegacyStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } + [TestMethod] public void TestIdUniqueness_DataRowString_LegacyStrategy() { // Arrange @@ -56,6 +60,7 @@ public void TestIdUniqueness_DataRowString_LegacyStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } + [TestMethod] public void TestIdUniqueness_DynamicDataArrays_LegacyStrategy() { // Arrange @@ -78,6 +83,7 @@ public void TestIdUniqueness_DynamicDataArrays_LegacyStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } + [TestMethod] public void TestIdUniqueness_DynamicDataTuple_LegacyStrategy() { // Arrange @@ -99,6 +105,7 @@ public void TestIdUniqueness_DynamicDataTuple_LegacyStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } + [TestMethod] public void TestIdUniqueness_DynamicDataGenericCollections_LegacyStrategy() { // Arrange @@ -122,6 +129,7 @@ public void TestIdUniqueness_DynamicDataGenericCollections_LegacyStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceArrays_LegacyStrategy() { // Arrange @@ -144,6 +152,7 @@ public void TestIdUniqueness_TestDataSourceArrays_LegacyStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceTuples_LegacyStrategy() { // Arrange @@ -165,6 +174,7 @@ public void TestIdUniqueness_TestDataSourceTuples_LegacyStrategy() testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } + [TestMethod] public void TestIdUniqueness_TestDataSourceGenericCollections_LegacyStrategy() { // Arrange diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Utilities/CLITestBase.discovery.cs b/test/IntegrationTests/MSTest.IntegrationTests/Utilities/CLITestBase.discovery.cs index 12e2592fd6..4845949c08 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Utilities/CLITestBase.discovery.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Utilities/CLITestBase.discovery.cs @@ -15,11 +15,9 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; -using TestFramework.ForTestingMSTest; - namespace Microsoft.MSTestV2.CLIAutomation; -public partial class CLITestBase : TestContainer +public partial class CLITestBase { internal ImmutableArray DiscoverTests(string assemblyPath, string testCaseFilter = null) { diff --git a/test/Utilities/Automation.CLI/CLITestBase.common.cs b/test/Utilities/Automation.CLI/CLITestBase.common.cs index 35426ea724..969c488f3b 100644 --- a/test/Utilities/Automation.CLI/CLITestBase.common.cs +++ b/test/Utilities/Automation.CLI/CLITestBase.common.cs @@ -5,11 +5,9 @@ using FluentAssertions; -using TestFramework.ForTestingMSTest; - namespace Microsoft.MSTestV2.CLIAutomation; -public partial class CLITestBase : TestContainer +public partial class CLITestBase { private const string Configuration = #if DEBUG