diff --git a/TestFx.sln b/TestFx.sln index f7531fe7c..3b8143dd1 100644 --- a/TestFx.sln +++ b/TestFx.sln @@ -188,7 +188,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Net6", "Net6", "{35D010CC-C src\Adapter\Build\Net6\MSTest.TestFramework.targets = src\Adapter\Build\Net6\MSTest.TestFramework.targets EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReferencedProjectFromDataSourceTest", "test\E2ETests\TestAssets\ReferencedProjectFromDataSourceTest\ReferencedProjectFromDataSourceTest.csproj", "{6B4DE65C-4162-4C52-836A-8F9FA901814A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibProjectReferencedByDataSourceTest", "test\E2ETests\TestAssets\LibProjectReferencedByDataSourceTest\LibProjectReferencedByDataSourceTest.csproj", "{6B4DE65C-4162-4C52-836A-8F9FA901814A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscoverInternalsProject", "test\E2ETests\TestAssets\DiscoverInternalsProject\DiscoverInternalsProject.csproj", "{44A504D9-A0D6-427D-BFB2-DB144A74F0D5}" EndProject @@ -198,6 +198,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestFramework.ForTestingMST EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HierarchyProject", "test\E2ETests\TestAssets\HierarchyProject\HierarchyProject.csproj", "{94A4DAA8-9645-4161-91F6-11EB1AD70EFC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicDataTestProject", "test\E2ETests\TestAssets\DynamicDataTestProject\DynamicDataTestProject.csproj", "{B90E0931-2E90-4CE9-B107-ECD8E40C6B6C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -344,6 +346,10 @@ Global {94A4DAA8-9645-4161-91F6-11EB1AD70EFC}.Debug|Any CPU.Build.0 = Debug|Any CPU {94A4DAA8-9645-4161-91F6-11EB1AD70EFC}.Release|Any CPU.ActiveCfg = Release|Any CPU {94A4DAA8-9645-4161-91F6-11EB1AD70EFC}.Release|Any CPU.Build.0 = Release|Any CPU + {B90E0931-2E90-4CE9-B107-ECD8E40C6B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B90E0931-2E90-4CE9-B107-ECD8E40C6B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B90E0931-2E90-4CE9-B107-ECD8E40C6B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B90E0931-2E90-4CE9-B107-ECD8E40C6B6C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -403,6 +409,7 @@ Global {66608D86-416A-49AF-A937-C47F7E4586AE} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8} {0685FBC3-C3A9-43A9-B15C-15BAA39705FE} = {33D3029D-E653-4929-BB31-C714178C4BEE} {94A4DAA8-9645-4161-91F6-11EB1AD70EFC} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8} + {B90E0931-2E90-4CE9-B107-ECD8E40C6B6C} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {31E0F4D5-975A-41CC-933E-545B2201FAF9} diff --git a/test/E2ETests/DiscoveryAndExecutionTests/DataRowTests.cs b/test/E2ETests/DiscoveryAndExecutionTests/DataRowTests.cs deleted file mode 100644 index 83f11a4d0..000000000 --- a/test/E2ETests/DiscoveryAndExecutionTests/DataRowTests.cs +++ /dev/null @@ -1,169 +0,0 @@ -// 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.IO; - -using Microsoft.MSTestV2.CLIAutomation; - -namespace Microsoft.MSTestV2.Smoke.DiscoveryAndExecutionTests; -public class DataRowTests : CLITestBase -{ - private const string TestAssembly = "DataRowTestProject.dll"; - - public void ExecuteOnlyDerivedClassDataRowsWhenBothBaseAndDerviedClassHasDataRows_SimpleDataRows() - { - // Arrange - var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); - - // Act - var testCases = DiscoverTests(assemblyPath, "TestCategory~DataRowSimple"); - var testResults = RunTests(assemblyPath, testCases); - - // Assert - VerifyE2E.TestsPassed( - testResults, - "DataRowTestMethod (BaseString1)", - "DataRowTestMethod (BaseString2)", - "DataRowTestMethod (BaseString3)", - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); - } - - public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_SimpleDataRows() - { - // Arrange - var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); - - // Act - var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DerivedClass&TestCategory~DataRowSimple"); - var testResults = RunTests(assemblyPath, testCases); - - // Assert - VerifyE2E.TestsPassed( - testResults, - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); - } - - public void DataRowsExecuteWithRequiredAndOptionalParameters() - { - // Arrange - var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); - - // Act - var testCases = DiscoverTests(assemblyPath, "TestCategory~DataRowSomeOptional"); - var testResults = RunTests(assemblyPath, testCases); - - // Assert - VerifyE2E.TestsPassed( - testResults, - "DataRowTestMethodWithSomeOptionalParameters (123)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString1)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString2,DerivedOptionalString3)"); - } - - public void DataRowsExecuteWithParamsArrayParameter() - { - // Arrange - var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); - - // Act - var testCases = DiscoverTests(assemblyPath, "TestCategory~DataRowParamsArgument"); - var testResults = RunTests(assemblyPath, testCases); - - // Assert - VerifyE2E.TestsPassed( - testResults, - "DataRowTestMethodWithParamsParameters (2)", - "DataRowTestMethodWithParamsParameters (2,DerivedSingleParamsArg)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2,DerivedParamsArg3)"); - } - - public void DataRowsFailWhenInvalidArgumentsProvided() - { - // Arrange - var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); - - // Act - var testCases = DiscoverTests(assemblyPath, "TestCategory~DataRowOptionalInvalidArguments"); - var testResults = RunTests(assemblyPath, testCases); - - // Assert - VerifyE2E.TestsPassed( - testResults, - "DataRowTestMethodFailsWithInvalidArguments ()", - "DataRowTestMethodFailsWithInvalidArguments (2)", - "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); - } - - public void DataRowsShouldSerializeDoublesProperly() - { - // Arrange - var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); - - // Act - var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowTestDouble"); - var testResults = RunTests(assemblyPath, testCases); - - // Assert - VerifyE2E.TestsPassed( - testResults, - "DataRowTestDouble (10.01,20.01)", - "DataRowTestDouble (10.02,20.02)"); - } - - public void DataRowsShouldSerializeMixedTypesProperly() - { - // Arrange - var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); - - // Act - var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowTestMixed"); - var testResults = RunTests(assemblyPath, testCases); - - // Assert - VerifyE2E.TestsPassed( - testResults, - "DataRowTestMixed (10,10,10,10,10,10,10,10)"); - } - - public void DataRowsShouldSerializeEnumsProperly() - { - // Arrange - var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); - - // Act - var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowEnums"); - var testResults = RunTests(assemblyPath, testCases); - - // Assert - VerifyE2E.TestsPassed( - testResults, - "DataRowEnums ()", - "DataRowEnums (Alfa)", - "DataRowEnums (Beta)", - "DataRowEnums (Gamma)"); - } - - public void DataRowsShouldHandleNonSerializableValues() - { - // Arrange - var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); - - // Act - var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowNonSerializable"); - var testResults = RunTests(assemblyPath, testCases); - - // Assert - VerifyE2E.TestsDiscovered( - testCases, - "DataRowNonSerializable"); - - VerifyE2E.TestsPassed( - testResults, - "DataRowNonSerializable (System.String)", - "DataRowNonSerializable (System.Int32)", - "DataRowNonSerializable (DataRowTestProject.DerivedClass)"); - } -} diff --git a/test/E2ETests/DiscoveryAndExecutionTests/TestDataSourceExtensibilityTests.cs b/test/E2ETests/DiscoveryAndExecutionTests/Parameterized tests/DataExtensibilityTests.cs similarity index 98% rename from test/E2ETests/DiscoveryAndExecutionTests/TestDataSourceExtensibilityTests.cs rename to test/E2ETests/DiscoveryAndExecutionTests/Parameterized tests/DataExtensibilityTests.cs index 5ebdbf171..3fbb170a0 100644 --- a/test/E2ETests/DiscoveryAndExecutionTests/TestDataSourceExtensibilityTests.cs +++ b/test/E2ETests/DiscoveryAndExecutionTests/Parameterized tests/DataExtensibilityTests.cs @@ -6,7 +6,7 @@ using System.IO; using Microsoft.MSTestV2.CLIAutomation; namespace Microsoft.MSTestV2.Smoke.DiscoveryAndExecutionTests; -public class TestDataSourceExtensibilityTests : CLITestBase +public class DataExtensibilityTests : CLITestBase { private const string TestAssembly = "FxExtensibilityTestProject.dll"; diff --git a/test/E2ETests/DiscoveryAndExecutionTests/TestDataSourceTests.cs b/test/E2ETests/DiscoveryAndExecutionTests/Parameterized tests/DataRowTests.cs similarity index 51% rename from test/E2ETests/DiscoveryAndExecutionTests/TestDataSourceTests.cs rename to test/E2ETests/DiscoveryAndExecutionTests/Parameterized tests/DataRowTests.cs index 2b3e3f741..9fabdf1f7 100644 --- a/test/E2ETests/DiscoveryAndExecutionTests/TestDataSourceTests.cs +++ b/test/E2ETests/DiscoveryAndExecutionTests/Parameterized tests/DataRowTests.cs @@ -6,25 +6,165 @@ using System.IO; using Microsoft.MSTestV2.CLIAutomation; namespace Microsoft.MSTestV2.Smoke.DiscoveryAndExecutionTests; -public class TestDataSourceTests : CLITestBase +public class DataRowTests : CLITestBase { - private const string TestAssembly = "DataSourceTestProject.dll"; + private const string TestAssembly = "DataRowTestProject.dll"; - public void ExecuteDynamicDataTests() + public void ExecuteOnlyDerivedClassDataRowsWhenBothBaseAndDerivedClassHasDataRows_SimpleDataRows() { // Arrange var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); // Act - var testCases = DiscoverTests(assemblyPath, "DynamicDataTest"); + var testCases = DiscoverTests(assemblyPath, "TestCategory~DataRowSimple"); var testResults = RunTests(assemblyPath, testCases); // Assert - VerifyE2E.ContainsTestsPassed( + VerifyE2E.TestsPassed( testResults, - "DynamicDataTest (John;Doe,DataSourceTestProject.ITestDataSourceTests.User)"); + "DataRowTestMethod (BaseString1)", + "DataRowTestMethod (BaseString2)", + "DataRowTestMethod (BaseString3)", + "DataRowTestMethod (DerivedString1)", + "DataRowTestMethod (DerivedString2)"); + } - VerifyE2E.FailedTestCount(testResults, 0); + public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_SimpleDataRows() + { + // Arrange + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); + + // Act + var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DerivedClass&TestCategory~DataRowSimple"); + var testResults = RunTests(assemblyPath, testCases); + + // Assert + VerifyE2E.TestsPassed( + testResults, + "DataRowTestMethod (DerivedString1)", + "DataRowTestMethod (DerivedString2)"); + } + + public void DataRowsExecuteWithRequiredAndOptionalParameters() + { + // Arrange + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); + + // Act + var testCases = DiscoverTests(assemblyPath, "TestCategory~DataRowSomeOptional"); + var testResults = RunTests(assemblyPath, testCases); + + // Assert + VerifyE2E.TestsPassed( + testResults, + "DataRowTestMethodWithSomeOptionalParameters (123)", + "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString1)", + "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString2,DerivedOptionalString3)"); + } + + public void DataRowsExecuteWithParamsArrayParameter() + { + // Arrange + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); + + // Act + var testCases = DiscoverTests(assemblyPath, "TestCategory~DataRowParamsArgument"); + var testResults = RunTests(assemblyPath, testCases); + + // Assert + VerifyE2E.TestsPassed( + testResults, + "DataRowTestMethodWithParamsParameters (2)", + "DataRowTestMethodWithParamsParameters (2,DerivedSingleParamsArg)", + "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2)", + "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2,DerivedParamsArg3)"); + } + + public void DataRowsFailWhenInvalidArgumentsProvided() + { + // Arrange + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); + + // Act + var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowTests_Regular&TestCategory~DataRowOptionalInvalidArguments"); + var testResults = RunTests(assemblyPath, testCases); + + // Assert + VerifyE2E.TestsPassed( + testResults, + "DataRowTestMethodFailsWithInvalidArguments ()", + "DataRowTestMethodFailsWithInvalidArguments (2)", + "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); + } + + public void DataRowsShouldSerializeDoublesProperly() + { + // Arrange + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); + + // Act + var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowTests_Regular.DataRowTestDouble"); + var testResults = RunTests(assemblyPath, testCases); + + // Assert + VerifyE2E.TestsPassed( + testResults, + "DataRowTestDouble (10.01,20.01)", + "DataRowTestDouble (10.02,20.02)"); + } + + public void DataRowsShouldSerializeMixedTypesProperly() + { + // Arrange + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); + + // Act + var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowTests_DerivedClass.DataRowTestMixed"); + var testResults = RunTests(assemblyPath, testCases); + + // Assert + VerifyE2E.TestsPassed( + testResults, + "DataRowTestMixed (10,10,10,10,10,10,10,10)"); + } + + public void DataRowsShouldSerializeEnumsProperly() + { + // Arrange + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); + + // Act + var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowTests_DerivedClass.DataRowEnums"); + var testResults = RunTests(assemblyPath, testCases); + + // Assert + VerifyE2E.TestsPassed( + testResults, + "DataRowEnums ()", + "DataRowEnums (Alfa)", + "DataRowEnums (Beta)", + "DataRowEnums (Gamma)"); + } + + public void DataRowsShouldHandleNonSerializableValues() + { + // Arrange + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); + + // Act + var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowTests_DerivedClass.DataRowNonSerializable"); + var testResults = RunTests(assemblyPath, testCases); + + // Assert + VerifyE2E.TestsDiscovered( + testCases, + "DataRowNonSerializable"); + + VerifyE2E.TestsPassed( + testResults, + "DataRowNonSerializable (System.String)", + "DataRowNonSerializable (System.Int32)", + "DataRowNonSerializable (DataRowTestProject.DataRowTests_DerivedClass)"); } public void ExecuteDataRowTests_Enums() @@ -116,17 +256,17 @@ public class TestDataSourceTests : CLITestBase testResults, "DataRowNonSerializable (System.String)", "DataRowNonSerializable (System.Int32)", - "DataRowNonSerializable (DataSourceTestProject.ITestDataSourceTests.DataRowTests_Enums)"); + "DataRowNonSerializable (DataRowTestProject.DataRowTests_Enums)"); VerifyE2E.FailedTestCount(testResults, 0); } - public void ExecuteRegular_DataRowTests() + public void ExecuteDataRowTests_Regular() { // Arrange var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); // Act - var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~Regular_DataRowTests"); + var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowTests_Regular"); var testResults = RunTests(assemblyPath, testCases); // Assert @@ -154,26 +294,4 @@ public class TestDataSourceTests : CLITestBase VerifyE2E.FailedTestCount(testResults, 0); } - - // TODO @haplois | @evangelink: This test fails under CI - will be fixed in a future PR (Marked as private to ignore the test) - private void ExecuteCsvTestDataSourceTests() - { - // Arrange - var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : GetAssetFullPath(TestAssembly); - - // Act - var testCases = DiscoverTests(assemblyPath, "CsvTestMethod"); - var testResults = RunTests(assemblyPath, testCases); - - // Assert - VerifyE2E.ContainsTestsPassed( - testResults, - "CsvTestMethod (Data Row 0)", - "CsvTestMethod (Data Row 2)"); - - VerifyE2E.ContainsTestsFailed( - testResults, - "CsvTestMethod (Data Row 1)", - "CsvTestMethod (Data Row 3)"); - } } diff --git a/test/E2ETests/DiscoveryAndExecutionTests/DataSourceTests.cs b/test/E2ETests/DiscoveryAndExecutionTests/Parameterized tests/DataSourceTests.cs similarity index 100% rename from test/E2ETests/DiscoveryAndExecutionTests/DataSourceTests.cs rename to test/E2ETests/DiscoveryAndExecutionTests/Parameterized tests/DataSourceTests.cs diff --git a/test/E2ETests/DiscoveryAndExecutionTests/Parameterized tests/DynamicDataTests.cs b/test/E2ETests/DiscoveryAndExecutionTests/Parameterized tests/DynamicDataTests.cs new file mode 100644 index 000000000..362cb4d09 --- /dev/null +++ b/test/E2ETests/DiscoveryAndExecutionTests/Parameterized tests/DynamicDataTests.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.MSTestV2.CLIAutomation; + +namespace Microsoft.MSTestV2.Smoke.DiscoveryAndExecutionTests; +public class DynamicDataTests : CLITestBase +{ + private const string TestAssembly = "DynamicDataTestProject.dll"; + + public void ExecuteDynamicDataTests() + { + // Arrange + var assemblyPath = GetAssetFullPath(TestAssembly); + + // Act + var testCases = DiscoverTests(assemblyPath); + var testResults = RunTests(assemblyPath, testCases); + + // Assert + VerifyE2E.ContainsTestsPassed( + testResults, + "DynamicDataTest_SourceMethod (John;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourceMethod (Jane;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourceProperty (John;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourceProperty (Jane;Doe,LibProjectReferencedByDataSourceTest.User)", + "Custom DynamicDataTestMethod DynamicDataTest_SourceMethod_CustomDisplayName with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourceMethod_CustomDisplayName with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourceProperty_CustomDisplayName with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourceProperty_CustomDisplayName with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceMethod_CustomDisplayNameOtherType with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceMethod_CustomDisplayNameOtherType with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceProperty_CustomDisplayNameOtherType with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceProperty_CustomDisplayNameOtherType with 2 parameters", + "DynamicDataTest_SourceMethodOtherType (John;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourceMethodOtherType (Jane;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourcePropertyOtherType (John;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourcePropertyOtherType (Jane;Doe,LibProjectReferencedByDataSourceTest.User)", + "Custom DynamicDataTestMethod DynamicDataTest_SourceMethodOtherType_CustomDisplayName with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourceMethodOtherType_CustomDisplayName with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceMethodOtherType_CustomDisplayNameOtherType with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceMethodOtherType_CustomDisplayNameOtherType with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourcePropertyOtherType_CustomDisplayName with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourcePropertyOtherType_CustomDisplayName with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourcePropertyOtherType_CustomDisplayNameOtherType with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourcePropertyOtherType_CustomDisplayNameOtherType with 2 parameters", + "DynamicDataTestWithTestCategory (John;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTestWithTestCategory (Jane;Doe,LibProjectReferencedByDataSourceTest.User)"); + + VerifyE2E.FailedTestCount(testResults, 0); + } + + public void ExecuteDynamicDataTestsWithCategoryFilter() + { + // Arrange + var assemblyPath = GetAssetFullPath(TestAssembly); + + // Act + var testCases = DiscoverTests(assemblyPath, "TestCategory~DynamicDataWithCategory"); + var testResults = RunTests(assemblyPath, testCases); + + // Assert + VerifyE2E.ContainsTestsPassed( + testResults, + "DynamicDataTestWithTestCategory (John;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTestWithTestCategory (Jane;Doe,LibProjectReferencedByDataSourceTest.User)"); + + VerifyE2E.FailedTestCount(testResults, 0); + } +} diff --git a/test/E2ETests/Smoke.E2E.Tests/DataRowTests.cs b/test/E2ETests/Smoke.E2E.Tests/DataRowTests.cs deleted file mode 100644 index ade436717..000000000 --- a/test/E2ETests/Smoke.E2E.Tests/DataRowTests.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.MSTestV2.CLIAutomation; - -namespace MSTestAdapter.Smoke.E2ETests; -public class DataRowTests : CLITestBase -{ - private const string TestAssembly = "DataRowTestProject.dll"; - - public void ExecuteOnlyDerivedClassDataRowsWhenBothBaseAndDerviedClassHasDataRows_SimpleDataRows() - { - InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "TestCategory~DataRowSimple"); - - ValidatePassedTestsContain( - "DataRowTestMethod (BaseString1)", - "DataRowTestMethod (BaseString2)", - "DataRowTestMethod (BaseString3)", - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); - - // 3 tests of BaseClass.DataRowTestMethod - 3 data row results and no parent result - // 2 tests of DerivedClass.DataRowTestMethod - 2 data row results and no parent result - // Total 5 tests - Making sure that DerivedClass doesn't run BaseClass tests - ValidatePassedTestsCount(5); - } - - public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_SimpleDataRows() - { - InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "FullyQualifiedName~DerivedClass&TestCategory~DataRowSimple"); - - ValidatePassedTestsContain( - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); - - // 2 tests of DerivedClass.DataRowTestMethod - 2 datarow result and no parent result - ValidatePassedTestsCount(2); - } - - public void DataRowsExecuteWithRequiredAndOptionalParameters() - { - InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "TestCategory~DataRowSomeOptional"); - - ValidatePassedTestsContain( - "DataRowTestMethodWithSomeOptionalParameters (123)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString1)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString2,DerivedOptionalString3)"); - - // 3 tests of DerivedClass.DataRowTestMethodWithSomeOptionalParameters - 3 datarow result and no parent result - ValidatePassedTestsCount(3); - } - - public void DataRowsExecuteWithAllOptionalParameters() - { - InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "TestCategory~DataRowAllOptional"); - - ValidatePassedTestsContain( - "DataRowTestMethodWithAllOptionalParameters ()", - "DataRowTestMethodWithAllOptionalParameters (123)", - "DataRowTestMethodWithAllOptionalParameters (123,DerivedOptionalString4)", - "DataRowTestMethodWithAllOptionalParameters (123,DerivedOptionalString5,DerivedOptionalString6)"); - - // 4 tests of DerivedClass.DataRowTestMethodWithAllOptionalParameters - 4 datarow result and no parent result - ValidatePassedTestsCount(4); - } - - public void DataRowsExecuteWithParamsArrayParameter() - { - InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "TestCategory~DataRowParamsArgument"); - - ValidatePassedTestsContain( - "DataRowTestMethodWithParamsParameters (2)", - "DataRowTestMethodWithParamsParameters (2,DerivedSingleParamsArg)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2,DerivedParamsArg3)"); - - // 4 tests of DerivedClass.DataRowTestMethodWithParamsParameters - 4 datarow result and no parent result - ValidatePassedTestsCount(4); - } - - public void DataRowsFailWhenInvalidArgumentsProvided() - { - InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "TestCategory~DataRowOptionalInvalidArguments"); - - ValidatePassedTestsContain( - "DataRowTestMethodFailsWithInvalidArguments ()", - "DataRowTestMethodFailsWithInvalidArguments (2)", - "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); - - // 3 tests of DerivedClass.DataRowTestMethodFailsWithInvalidArguments - 3 datarow result and no parent result - ValidatePassedTestsCount(3); - } -} diff --git a/test/E2ETests/Smoke.E2E.Tests/DynamicDataExtensibilityTests.cs b/test/E2ETests/Smoke.E2E.Tests/DynamicDataExtensibilityTests.cs deleted file mode 100644 index e9263a740..000000000 --- a/test/E2ETests/Smoke.E2E.Tests/DynamicDataExtensibilityTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.MSTestV2.CLIAutomation; - -namespace MSTestAdapter.Smoke.E2ETests; -public class DynamicDataExtensibilityTests : CLITestBase -{ - private const string TestAssembly = "FxExtensibilityTestProject.dll"; - - public void ExecuteDynamicDataExtensibilityTests() - { - InvokeVsTestForExecution(new string[] { TestAssembly }); - ValidatePassedTestsContain( - "DynamicDataTestMethod1 (string,2,True)", - "DynamicDataTestMethod2 (string,4,True)", - "DynamicDataTestMethod3 (string,2,True)", - "DynamicDataTestMethod3 (string,4,True)"); - - ValidatePassedTestsContain( - "DynamicDataTestMethod4 (string,2,True)", - "DynamicDataTestMethod5 (string,4,True)", - "DynamicDataTestMethod6 (string,2,True)", - "DynamicDataTestMethod6 (string,4,True)"); - } -} diff --git a/test/E2ETests/Smoke.E2E.Tests/CustomTestExecutionExtensibilityTests.cs b/test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DataExtensibilityTests.cs similarity index 65% rename from test/E2ETests/Smoke.E2E.Tests/CustomTestExecutionExtensibilityTests.cs rename to test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DataExtensibilityTests.cs index 1de0737bd..649249abb 100644 --- a/test/E2ETests/Smoke.E2E.Tests/CustomTestExecutionExtensibilityTests.cs +++ b/test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DataExtensibilityTests.cs @@ -4,10 +4,32 @@ using Microsoft.MSTestV2.CLIAutomation; namespace MSTestAdapter.Smoke.E2ETests; -public class CustomTestExecutionExtensibilityTests : CLITestBase +public class DataExtensibilityTests : CLITestBase { private const string TestAssembly = "FxExtensibilityTestProject.dll"; + public void ExecuteTestDataSourceExtensibilityTests() + { + InvokeVsTestForExecution(new string[] { TestAssembly }); + ValidatePassedTestsContain("CustomTestDataSourceTestMethod1 (1,2,3)", "CustomTestDataSourceTestMethod1 (4,5,6)"); + } + + public void ExecuteDynamicDataExtensibilityTests() + { + InvokeVsTestForExecution(new string[] { TestAssembly }); + ValidatePassedTestsContain( + "DynamicDataTestMethod1 (string,2,True)", + "DynamicDataTestMethod2 (string,4,True)", + "DynamicDataTestMethod3 (string,2,True)", + "DynamicDataTestMethod3 (string,4,True)"); + + ValidatePassedTestsContain( + "DynamicDataTestMethod4 (string,2,True)", + "DynamicDataTestMethod5 (string,4,True)", + "DynamicDataTestMethod6 (string,2,True)", + "DynamicDataTestMethod6 (string,4,True)"); + } + public void ExecuteCustomTestExtensibilityTests() { InvokeVsTestForExecution(new string[] { TestAssembly }); diff --git a/test/E2ETests/Smoke.E2E.Tests/TestDataSourceTests.cs b/test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DataRowTests.cs similarity index 53% rename from test/E2ETests/Smoke.E2E.Tests/TestDataSourceTests.cs rename to test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DataRowTests.cs index f0c5cb6fd..dd4828eb3 100644 --- a/test/E2ETests/Smoke.E2E.Tests/TestDataSourceTests.cs +++ b/test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DataRowTests.cs @@ -4,22 +4,91 @@ using Microsoft.MSTestV2.CLIAutomation; namespace MSTestAdapter.Smoke.E2ETests; -public class TestDataSourceTests : CLITestBase +public class DataRowTests : CLITestBase { - private const string TestAssembly = "DataSourceTestProject.dll"; + private const string TestAssembly = "DataRowTestProject.dll"; - public void ExecuteDynamicDataTests() + public void ExecuteOnlyDerivedClassDataRowsWhenBothBaseAndDerivedClassHasDataRows_SimpleDataRows() { - // Arrange & Act - InvokeVsTestForExecution( - new string[] { TestAssembly }, - testCaseFilter: "DynamicDataTest"); + InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "TestCategory~DataRowSimple"); - // Assert - ValidatePassedTests( - "DynamicDataTest (John;Doe,DataSourceTestProject.ITestDataSourceTests.User)"); + ValidatePassedTestsContain( + "DataRowTestMethod (BaseString1)", + "DataRowTestMethod (BaseString2)", + "DataRowTestMethod (BaseString3)", + "DataRowTestMethod (DerivedString1)", + "DataRowTestMethod (DerivedString2)"); - ValidateFailedTestsCount(0); + // 3 tests of BaseClass.DataRowTestMethod - 3 data row results and no parent result + // 2 tests of DerivedClass.DataRowTestMethod - 2 data row results and no parent result + // Total 5 tests - Making sure that DerivedClass doesn't run BaseClass tests + ValidatePassedTestsCount(5); + } + + public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_SimpleDataRows() + { + InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "FullyQualifiedName~DerivedClass&TestCategory~DataRowSimple"); + + ValidatePassedTestsContain( + "DataRowTestMethod (DerivedString1)", + "DataRowTestMethod (DerivedString2)"); + + // 2 tests of DerivedClass.DataRowTestMethod - 2 datarow result and no parent result + ValidatePassedTestsCount(2); + } + + public void DataRowsExecuteWithRequiredAndOptionalParameters() + { + InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "TestCategory~DataRowSomeOptional"); + + ValidatePassedTestsContain( + "DataRowTestMethodWithSomeOptionalParameters (123)", + "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString1)", + "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString2,DerivedOptionalString3)"); + + // 3 tests of DerivedClass.DataRowTestMethodWithSomeOptionalParameters - 3 datarow result and no parent result + ValidatePassedTestsCount(3); + } + + public void DataRowsExecuteWithAllOptionalParameters() + { + InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "TestCategory~DataRowAllOptional"); + + ValidatePassedTestsContain( + "DataRowTestMethodWithAllOptionalParameters ()", + "DataRowTestMethodWithAllOptionalParameters (123)", + "DataRowTestMethodWithAllOptionalParameters (123,DerivedOptionalString4)", + "DataRowTestMethodWithAllOptionalParameters (123,DerivedOptionalString5,DerivedOptionalString6)"); + + // 4 tests of DerivedClass.DataRowTestMethodWithAllOptionalParameters - 4 datarow result and no parent result + ValidatePassedTestsCount(4); + } + + public void DataRowsExecuteWithParamsArrayParameter() + { + InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "TestCategory~DataRowParamsArgument"); + + ValidatePassedTestsContain( + "DataRowTestMethodWithParamsParameters (2)", + "DataRowTestMethodWithParamsParameters (2,DerivedSingleParamsArg)", + "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2)", + "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2,DerivedParamsArg3)"); + + // 4 tests of DerivedClass.DataRowTestMethodWithParamsParameters - 4 datarow result and no parent result + ValidatePassedTestsCount(4); + } + + public void DataRowsFailWhenInvalidArgumentsProvided() + { + InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "FullyQualifiedName~DataRowTests_Regular&TestCategory~DataRowOptionalInvalidArguments"); + + ValidatePassedTestsContain( + "DataRowTestMethodFailsWithInvalidArguments ()", + "DataRowTestMethodFailsWithInvalidArguments (2)", + "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); + + // 3 tests of DerivedClass.DataRowTestMethodFailsWithInvalidArguments - 3 datarow result and no parent result + ValidatePassedTestsCount(3); } public void ExecuteDataRowTests_Enums() @@ -105,7 +174,7 @@ public class TestDataSourceTests : CLITestBase ValidatePassedTests( "DataRowNonSerializable (System.String)", "DataRowNonSerializable (System.Int32)", - "DataRowNonSerializable (DataSourceTestProject.ITestDataSourceTests.DataRowTests_Enums)"); + "DataRowNonSerializable (DataRowTestProject.DataRowTests_Enums)"); ValidateFailedTestsCount(0); } @@ -115,7 +184,7 @@ public class TestDataSourceTests : CLITestBase // Arrange & Act InvokeVsTestForExecution( new string[] { TestAssembly }, - testCaseFilter: "FullyQualifiedName~Regular_DataRowTests"); + testCaseFilter: "FullyQualifiedName~DataRowTests_Regular"); // Assert ValidatePassedTests( @@ -141,23 +210,4 @@ public class TestDataSourceTests : CLITestBase ValidateFailedTestsCount(0); } - - // TODO @haplois | @evangelink: This test fails under CI - will be fixed in a future PR (marked as private to ignore the test) - private void ExecuteCsvTestDataSourceTests() - { - // Arrange & Act - InvokeVsTestForExecution( - new string[] { TestAssembly }, - testCaseFilter: "CsvTestMethod"); - - // Assert - ValidatePassedTests( - "CsvTestMethod (Data Row 0)", - "CsvTestMethod (Data Row 2)"); - - ValidateFailedTests( - TestAssembly, - "CsvTestMethod (Data Row 1)", - "CsvTestMethod (Data Row 3)"); - } } diff --git a/test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DataSourceTests.cs b/test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DataSourceTests.cs new file mode 100644 index 000000000..3394e3edf --- /dev/null +++ b/test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DataSourceTests.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.MSTestV2.CLIAutomation; + +namespace MSTestAdapter.Smoke.E2ETests; +public class DataSourceTests : CLITestBase +{ + private const string TestAssembly = "DataSourceTestProject.dll"; + + // TODO @haplois | @evangelink: This test fails under CI - will be fixed in a future PR (marked as private to ignore the test) + private void ExecuteCsvTestDataSourceTests() + { + // Arrange & Act + InvokeVsTestForExecution( + new string[] { TestAssembly }, + testCaseFilter: "CsvTestMethod"); + + // Assert + ValidatePassedTests( + "CsvTestMethod (Data Row 0)", + "CsvTestMethod (Data Row 2)"); + + ValidateFailedTests( + TestAssembly, + "CsvTestMethod (Data Row 1)", + "CsvTestMethod (Data Row 3)"); + } +} diff --git a/test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DynamicDataTests.cs b/test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DynamicDataTests.cs new file mode 100644 index 000000000..4aa4b3210 --- /dev/null +++ b/test/E2ETests/Smoke.E2E.Tests/Parameterized tests/DynamicDataTests.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.MSTestV2.CLIAutomation; + +namespace MSTestAdapter.Smoke.E2ETests; +public class DynamicDataTests : CLITestBase +{ + private const string TestAssembly = "DynamicDataTestProject.dll"; + + public void ExecuteDynamicDataTests() + { + // Arrange & Act + InvokeVsTestForExecution( + new string[] { TestAssembly }, + testCaseFilter: "DynamicDataTest"); + + // Assert + ValidatePassedTests( + "DynamicDataTest_SourceMethod (John;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourceMethod (Jane;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourceProperty (John;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourceProperty (Jane;Doe,LibProjectReferencedByDataSourceTest.User)", + "Custom DynamicDataTestMethod DynamicDataTest_SourceMethod_CustomDisplayName with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourceMethod_CustomDisplayName with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourceProperty_CustomDisplayName with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourceProperty_CustomDisplayName with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceMethod_CustomDisplayNameOtherType with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceMethod_CustomDisplayNameOtherType with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceProperty_CustomDisplayNameOtherType with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceProperty_CustomDisplayNameOtherType with 2 parameters", + "DynamicDataTest_SourceMethodOtherType (John;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourceMethodOtherType (Jane;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourcePropertyOtherType (John;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTest_SourcePropertyOtherType (Jane;Doe,LibProjectReferencedByDataSourceTest.User)", + "Custom DynamicDataTestMethod DynamicDataTest_SourceMethodOtherType_CustomDisplayName with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourceMethodOtherType_CustomDisplayName with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceMethodOtherType_CustomDisplayNameOtherType with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourceMethodOtherType_CustomDisplayNameOtherType with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourcePropertyOtherType_CustomDisplayName with 2 parameters", + "Custom DynamicDataTestMethod DynamicDataTest_SourcePropertyOtherType_CustomDisplayName with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourcePropertyOtherType_CustomDisplayNameOtherType with 2 parameters", + "UserDynamicDataTestMethod DynamicDataTest_SourcePropertyOtherType_CustomDisplayNameOtherType with 2 parameters", + "DynamicDataTestWithTestCategory (John;Doe,LibProjectReferencedByDataSourceTest.User)", + "DynamicDataTestWithTestCategory (Jane;Doe,LibProjectReferencedByDataSourceTest.User)"); + + ValidateFailedTestsCount(0); + } +} diff --git a/test/E2ETests/Smoke.E2E.Tests/TestDataSourceExtensibilityTests.cs b/test/E2ETests/Smoke.E2E.Tests/TestDataSourceExtensibilityTests.cs deleted file mode 100644 index 373f01510..000000000 --- a/test/E2ETests/Smoke.E2E.Tests/TestDataSourceExtensibilityTests.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.MSTestV2.CLIAutomation; - -namespace MSTestAdapter.Smoke.E2ETests; -public class TestDataSourceExtensibilityTests : CLITestBase -{ - private const string TestAssembly = "FxExtensibilityTestProject.dll"; - - public void ExecuteTestDataSourceExtensibilityTests() - { - InvokeVsTestForExecution(new string[] { TestAssembly }); - ValidatePassedTestsContain("CustomTestDataSourceTestMethod1 (1,2,3)", "CustomTestDataSourceTestMethod1 (4,5,6)"); - } -} diff --git a/test/E2ETests/TestAssets/DataRowTestProject/DataRowTestProject.csproj b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTestProject.csproj index bcd20b2f4..c624dcc42 100644 --- a/test/E2ETests/TestAssets/DataRowTestProject/DataRowTestProject.csproj +++ b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTestProject.csproj @@ -1,4 +1,5 @@  + net462 false @@ -10,8 +11,4 @@ - - - - diff --git a/test/E2ETests/TestAssets/DataRowTestProject/BaseClass.cs b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_BaseClass.cs similarity index 93% rename from test/E2ETests/TestAssets/DataRowTestProject/BaseClass.cs rename to test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_BaseClass.cs index 44c18135f..f6969bab0 100644 --- a/test/E2ETests/TestAssets/DataRowTestProject/BaseClass.cs +++ b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_BaseClass.cs @@ -1,12 +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. - using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DataRowTestProject; + [TestClass] -public class BaseClass +public class DataRowTests_BaseClass { [TestCategory("DataRowSimple")] [TestMethod] diff --git a/test/E2ETests/TestAssets/DataRowTestProject/DerivedClass.cs b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_DerivedClass.cs similarity index 96% rename from test/E2ETests/TestAssets/DataRowTestProject/DerivedClass.cs rename to test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_DerivedClass.cs index a8339e4b8..a541311ce 100644 --- a/test/E2ETests/TestAssets/DataRowTestProject/DerivedClass.cs +++ b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_DerivedClass.cs @@ -1,14 +1,14 @@ // 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; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DataRowTestProject; + [TestClass] -public class DerivedClass : BaseClass +public class DataRowTests_DerivedClass : DataRowTests_BaseClass { [TestCategory("DataRowSimple")] [TestMethod] @@ -99,7 +99,7 @@ public class DerivedClass : BaseClass [TestMethod] [DataRow(typeof(string))] [DataRow(typeof(int))] - [DataRow(typeof(DerivedClass))] + [DataRow(typeof(DataRowTests_DerivedClass))] public void DataRowNonSerializable(Type type) { Assert.IsTrue(true); diff --git a/test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataRowTests_Enums.cs b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_Enums.cs similarity index 98% rename from test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataRowTests_Enums.cs rename to test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_Enums.cs index ca2015093..adeecc5ef 100644 --- a/test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataRowTests_Enums.cs +++ b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_Enums.cs @@ -1,12 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. - using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; +namespace DataRowTestProject; -namespace DataSourceTestProject.ITestDataSourceTests; [TestClass] public class DataRowTests_Enums { diff --git a/test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataRowTests_NonSerializablePaths.cs b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_NonSerializablePaths.cs similarity index 90% rename from test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataRowTests_NonSerializablePaths.cs rename to test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_NonSerializablePaths.cs index 4a5658bbc..cbc6de1e8 100644 --- a/test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataRowTests_NonSerializablePaths.cs +++ b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_NonSerializablePaths.cs @@ -1,12 +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. - using Microsoft.VisualStudio.TestTools.UnitTesting; using System; -namespace DataSourceTestProject.ITestDataSourceTests; +namespace DataRowTestProject; + [TestClass] public class DataRowTests_NonSerializablePaths { diff --git a/test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataRowTests_Regular.cs b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_Regular.cs similarity index 95% rename from test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataRowTests_Regular.cs rename to test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_Regular.cs index 438f51e7b..4603cf9f7 100644 --- a/test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataRowTests_Regular.cs +++ b/test/E2ETests/TestAssets/DataRowTestProject/DataRowTests_Regular.cs @@ -1,14 +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. - using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; +namespace DataRowTestProject; -namespace DataSourceTestProject.ITestDataSourceTests; [TestClass] -public class Regular_DataRowTests +public class DataRowTests_Regular { [TestMethod] [DataRow(10)] diff --git a/test/E2ETests/TestAssets/DataSourceTestProject/DataSourceTestProject.csproj b/test/E2ETests/TestAssets/DataSourceTestProject/DataSourceTestProject.csproj index 6e73623c6..afeb11f14 100644 --- a/test/E2ETests/TestAssets/DataSourceTestProject/DataSourceTestProject.csproj +++ b/test/E2ETests/TestAssets/DataSourceTestProject/DataSourceTestProject.csproj @@ -8,7 +8,6 @@ - diff --git a/test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataSourceTests.cs b/test/E2ETests/TestAssets/DataSourceTestProject/DataSourceTests.cs similarity index 73% rename from test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataSourceTests.cs rename to test/E2ETests/TestAssets/DataSourceTestProject/DataSourceTests.cs index 703e6aeab..0279eee93 100644 --- a/test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DataSourceTests.cs +++ b/test/E2ETests/TestAssets/DataSourceTestProject/DataSourceTests.cs @@ -1,20 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. - using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; +namespace DataSourceTestProject; -namespace DataSourceTestProject.ITestDataSourceTests; [TestClass] -public class DataRowTests_Regular +public class DataSourceTests { - public TestContext TestContext - { - get; - set; - } + public TestContext TestContext { get; set; } [TestMethod, DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\a.csv", "a#csv", DataAccessMethod.Sequential)] public void CsvTestMethod() diff --git a/test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DynamicDataTests.cs b/test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DynamicDataTests.cs deleted file mode 100644 index 144cab864..000000000 --- a/test/E2ETests/TestAssets/DataSourceTestProject/ITestDataSourceTests/DynamicDataTests.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - - -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using System; -using System.Collections.Generic; - -namespace DataSourceTestProject.ITestDataSourceTests; -[TestClass] -public class DynamicDataTests -{ - [DataTestMethod()] - [DynamicData(nameof(GetParseUserDatas), DynamicDataSourceType.Method)] - public void DynamicDataTest(string userDatas, User expectedUser) - { - // Prepare - var srv = new UserService(); - - // Act - var user = srv.ParseUserDatas(userDatas); - - // Assert - Assert.AreNotSame(user, expectedUser); - Assert.AreEqual(user.FirstName, expectedUser.FirstName); - Assert.AreEqual(user.LastName, expectedUser.LastName); - } - - public static IEnumerable GetParseUserDatas() - { - yield return new object[] { - "John;Doe", - new User() - { - FirstName = "John", - LastName = "Doe" - } - }; - } -} diff --git a/test/E2ETests/TestAssets/DynamicDataTestProject/DataProvider.cs b/test/E2ETests/TestAssets/DynamicDataTestProject/DataProvider.cs new file mode 100644 index 000000000..0dfc72eb2 --- /dev/null +++ b/test/E2ETests/TestAssets/DynamicDataTestProject/DataProvider.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using LibProjectReferencedByDataSourceTest; + +using System.Collections.Generic; +using System.Reflection; + +namespace DynamicDataTestProject; + +public class DataProvider +{ + public static IEnumerable GetUserDataAndExceptedParsedUser() + { + yield return new object[] + { + "John;Doe", + new User() + { + FirstName = "John", + LastName = "Doe" + } + }; + + yield return new object[] + { + "Jane;Doe", + new User() + { + FirstName = "Jane", + LastName = "Doe" + } + }; + } + + public static IEnumerable UserDataAndExceptedParsedUser + { + get + { + yield return new object[] + { + "John;Doe", + new User() + { + FirstName = "John", + LastName = "Doe" + } + }; + + yield return new object[] + { + "Jane;Doe", + new User() + { + FirstName = "Jane", + LastName = "Doe" + } + }; + } + } + + public static string GetUserDynamicDataDisplayName(MethodInfo methodInfo, object[] data) + { + return string.Format("UserDynamicDataTestMethod {0} with {1} parameters", methodInfo.Name, data.Length); + } +} diff --git a/test/E2ETests/TestAssets/DynamicDataTestProject/DynamicDataTestProject.csproj b/test/E2ETests/TestAssets/DynamicDataTestProject/DynamicDataTestProject.csproj new file mode 100644 index 000000000..2af9fafd1 --- /dev/null +++ b/test/E2ETests/TestAssets/DynamicDataTestProject/DynamicDataTestProject.csproj @@ -0,0 +1,15 @@ + + + + net462 + false + false + $(RepoRoot)artifacts\TestAssets\ + + + + + + + + diff --git a/test/E2ETests/TestAssets/DynamicDataTestProject/DynamicDataTests.cs b/test/E2ETests/TestAssets/DynamicDataTestProject/DynamicDataTests.cs new file mode 100644 index 000000000..134226ad7 --- /dev/null +++ b/test/E2ETests/TestAssets/DynamicDataTestProject/DynamicDataTests.cs @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System.Collections.Generic; + +using LibProjectReferencedByDataSourceTest; + +using DynamicDataTestProject; +using System.Reflection; + +namespace DataSourceTestProject; + +[TestClass] +public class DynamicDataTests +{ + [DataTestMethod] + [DynamicData(nameof(GetParseUserData), DynamicDataSourceType.Method)] + public void DynamicDataTest_SourceMethod(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); + } + + [DataTestMethod] + [DynamicData(nameof(ParseUserData), DynamicDataSourceType.Property)] + public void DynamicDataTest_SourceProperty(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); + } + + [DataTestMethod] + [DynamicData(nameof(GetParseUserData), DynamicDataSourceType.Method, + DynamicDataDisplayName = nameof(GetCustomDynamicDataDisplayName))] + public void DynamicDataTest_SourceMethod_CustomDisplayName(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); + } + + [DataTestMethod] + [DynamicData(nameof(ParseUserData), DynamicDataSourceType.Property, + DynamicDataDisplayName = nameof(GetCustomDynamicDataDisplayName))] + public void DynamicDataTest_SourceProperty_CustomDisplayName(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); + } + + [DataTestMethod] + [DynamicData(nameof(GetParseUserData), DynamicDataSourceType.Method, + DynamicDataDisplayName = nameof(DataProvider.GetUserDynamicDataDisplayName), DynamicDataDisplayNameDeclaringType = typeof(DataProvider))] + public void DynamicDataTest_SourceMethod_CustomDisplayNameOtherType(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); // todo + } + + [DataTestMethod] + [DynamicData(nameof(ParseUserData), DynamicDataSourceType.Property, + DynamicDataDisplayName = nameof(DataProvider.GetUserDynamicDataDisplayName), DynamicDataDisplayNameDeclaringType = typeof(DataProvider))] + public void DynamicDataTest_SourceProperty_CustomDisplayNameOtherType(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); // todo + } + + [DataTestMethod] + [DynamicData(nameof(DataProvider.GetUserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataSourceType.Method)] + public void DynamicDataTest_SourceMethodOtherType(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); + } + + [DataTestMethod] + [DynamicData(nameof(DataProvider.UserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataSourceType.Property)] + public void DynamicDataTest_SourcePropertyOtherType(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); + } + + [DataTestMethod] + [DynamicData(nameof(DataProvider.GetUserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataSourceType.Method, + DynamicDataDisplayName = nameof(GetCustomDynamicDataDisplayName))] + public void DynamicDataTest_SourceMethodOtherType_CustomDisplayName(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); + } + + [DataTestMethod] + [DynamicData(nameof(DataProvider.UserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataSourceType.Property, + DynamicDataDisplayName = nameof(GetCustomDynamicDataDisplayName))] + public void DynamicDataTest_SourcePropertyOtherType_CustomDisplayName(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); + } + + [DataTestMethod] + [DynamicData(nameof(DataProvider.GetUserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataSourceType.Method, + DynamicDataDisplayName = nameof(DataProvider.GetUserDynamicDataDisplayName), DynamicDataDisplayNameDeclaringType = typeof(DataProvider))] + public void DynamicDataTest_SourceMethodOtherType_CustomDisplayNameOtherType(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); + } + + [DataTestMethod] + [DynamicData(nameof(DataProvider.UserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataSourceType.Property, + DynamicDataDisplayName = nameof(DataProvider.GetUserDynamicDataDisplayName), DynamicDataDisplayNameDeclaringType = typeof(DataProvider))] + public void DynamicDataTest_SourcePropertyOtherType_CustomDisplayNameOtherType(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); + } + + [TestCategory("DynamicDataWithCategory")] + [DataTestMethod] + [DynamicData(nameof(GetParseUserData), DynamicDataSourceType.Method)] + public void DynamicDataTestWithTestCategory(string userData, User expectedUser) + { + ParseAndAssert(userData, expectedUser); + } + + private static void ParseAndAssert(string userData, User expectedUser) + { + // Prepare + var service = new UserService(); + + // Act + var user = service.ParseUserData(userData); + + // Assert + Assert.AreNotSame(user, expectedUser); + Assert.AreEqual(user.FirstName, expectedUser.FirstName); + Assert.AreEqual(user.LastName, expectedUser.LastName); + } + + public static IEnumerable GetParseUserData() + { + yield return new object[] + { + "John;Doe", + new User() + { + FirstName = "John", + LastName = "Doe" + } + }; + + yield return new object[] + { + "Jane;Doe", + new User() + { + FirstName = "Jane", + LastName = "Doe" + } + }; + } + + public static IEnumerable ParseUserData + { + get + { + yield return new object[] + { + "John;Doe", + new User() + { + FirstName = "John", + LastName = "Doe" + } + }; + + yield return new object[] + { + "Jane;Doe", + new User() + { + FirstName = "Jane", + LastName = "Doe" + } + }; + } + } + + public static string GetCustomDynamicDataDisplayName(MethodInfo methodInfo, object[] data) + { + return string.Format("Custom DynamicDataTestMethod {0} with {1} parameters", methodInfo.Name, data.Length); + } +} diff --git a/test/E2ETests/TestAssets/ReferencedProjectFromDataSourceTest/ReferencedProjectFromDataSourceTest.csproj b/test/E2ETests/TestAssets/LibProjectReferencedByDataSourceTest/LibProjectReferencedByDataSourceTest.csproj similarity index 100% rename from test/E2ETests/TestAssets/ReferencedProjectFromDataSourceTest/ReferencedProjectFromDataSourceTest.csproj rename to test/E2ETests/TestAssets/LibProjectReferencedByDataSourceTest/LibProjectReferencedByDataSourceTest.csproj diff --git a/test/E2ETests/TestAssets/ReferencedProjectFromDataSourceTest/User.cs b/test/E2ETests/TestAssets/LibProjectReferencedByDataSourceTest/User.cs similarity index 61% rename from test/E2ETests/TestAssets/ReferencedProjectFromDataSourceTest/User.cs rename to test/E2ETests/TestAssets/LibProjectReferencedByDataSourceTest/User.cs index 7748023ea..a5eeec283 100644 --- a/test/E2ETests/TestAssets/ReferencedProjectFromDataSourceTest/User.cs +++ b/test/E2ETests/TestAssets/LibProjectReferencedByDataSourceTest/User.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace DataSourceTestProject.ITestDataSourceTests; +namespace LibProjectReferencedByDataSourceTest; public class User { @@ -12,14 +12,14 @@ public class User public class UserService { - public User ParseUserDatas(string datas) + public User ParseUserData(string data) { - var splittedDatas = datas.Split(';'); + var splittedData = data.Split(';'); return new User() { - FirstName = splittedDatas[0], - LastName = splittedDatas[1] + FirstName = splittedData[0], + LastName = splittedData[1] }; } }