From 81511fbaf325f8adee39e73e772bbc416d106566 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Fri, 31 May 2024 08:52:17 +0200 Subject: [PATCH 01/17] Improve display name when DataRow contains arrays --- .../Attributes/DataSource/DataRowAttribute.cs | 17 +++++++++++-- .../Attributes/DataRowAttributeTests.cs | 24 +++++++++++++++---- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index 61bc9e47c3..fed000a730 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// 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.Globalization; @@ -84,6 +84,19 @@ public DataRowAttribute(params object?[]? data) : data.AsEnumerable(); return string.Format(CultureInfo.CurrentCulture, FrameworkMessages.DataDrivenResultDisplayName, methodInfo.Name, - string.Join(",", displayData)); + GetObjectString(displayData)); } + + /// + /// Recursively resolve collections of objects to a proper string representation. + /// + private string GetObjectString(IEnumerable enumerable) => + string.Join( + ",", + enumerable.Select(x => + x == null + ? null + : x.GetType().IsArray + ? $"[{GetObjectString((object[])x)}]" + : x)); } diff --git a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs index 9f09e9d412..b330f51664 100644 --- a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// 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; @@ -120,7 +120,7 @@ public void GetDisplayNameForArrayOfOneItem() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod (System.String[])"); + Verify(displayName == "MyMethod ([a])"); } public void GetDisplayName_AfterOverriding_GetsTheNewDisplayName() @@ -147,7 +147,7 @@ public void GetDisplayNameForArrayOfMultipleItems() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod (System.String[])"); + Verify(displayName == "MyMethod ([a,b,c])"); } public void GetDisplayNameForMultipleArraysOfOneItem() @@ -161,7 +161,7 @@ public void GetDisplayNameForMultipleArraysOfOneItem() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod (System.String[],System.String[])"); + Verify(displayName == "MyMethod ([a],[1])"); } public void GetDisplayNameForMultipleArraysOfMultipleItems() @@ -175,7 +175,21 @@ public void GetDisplayNameForMultipleArraysOfMultipleItems() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod (System.String[],System.String[])"); + Verify(displayName == "MyMethod ([a,b,c],[1,2,3])"); + } + + public void GetDisplayNameForMultipleArraysOfArraysOfMultipleItems() + { + // Arrange + var dataRow = new DataRowAttribute(new[] { new[] { "a", "b", "c" }, new[] { "d", "e", "f" }, new[] { "g", "h", "i" } }, new[] { new[] { "1", "2", "3" }, new[] { "4", "5", "6" }, new[] { "7", "8", "9" } }); + var methodInfoMock = new Mock(); + methodInfoMock.SetupGet(x => x.Name).Returns("MyMethod"); + + // Act + string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); + + // Assert + Verify(displayName == "MyMethod ([[a,b,c],[d,e,f],[g,h,i]],[[1,2,3],[4,5,6],[7,8,9]])"); } private class DummyDataRowAttribute : DataRowAttribute From a07dd44a86be10d0e4339d2d56a12ac8109393ee Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Fri, 31 May 2024 09:14:23 +0200 Subject: [PATCH 02/17] Mark GetObjectString as static --- .../TestFramework/Attributes/DataSource/DataRowAttribute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index fed000a730..73f188001e 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -90,7 +90,7 @@ public DataRowAttribute(params object?[]? data) /// /// Recursively resolve collections of objects to a proper string representation. /// - private string GetObjectString(IEnumerable enumerable) => + private static string GetObjectString(IEnumerable enumerable) => string.Join( ",", enumerable.Select(x => From ec5b11562848d0599e36fa2ddd0566fc37b6b500 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Fri, 31 May 2024 10:34:34 +0200 Subject: [PATCH 03/17] Handle primitive types with boxing --- .../TestFramework/Attributes/DataSource/DataRowAttribute.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index 73f188001e..a32f2b3876 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -1,6 +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. +using System.Collections; using System.Globalization; using System.Reflection; @@ -97,6 +98,6 @@ private static string GetObjectString(IEnumerable enumerable) => x == null ? null : x.GetType().IsArray - ? $"[{GetObjectString((object[])x)}]" - : x)); + ? $"[{GetObjectString(((IEnumerable)x).Cast())}]" + : x.ToString())); } From 5595303d40713f44b9a8370c645fcdb38ee0b6f5 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Fri, 31 May 2024 10:44:56 +0200 Subject: [PATCH 04/17] Update tests with newly expected values, Add test for value type --- .../Parameterized tests/DataRowTests.cs | 36 +++++++++---------- .../TestId.DefaultStrategy.cs | 6 ++-- .../TestId.DisplayNameStrategy.cs | 8 ++--- .../TestId.FullyQualifiedStrategy.cs | 6 ++-- .../TestId.LegacyStrategy.cs | 6 ++-- .../Parameterized tests/DataRowTests.cs | 36 +++++++++---------- .../Attributes/DataRowAttributeTests.cs | 14 ++++++++ 7 files changed, 63 insertions(+), 49 deletions(-) diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs index 115a02c03b..2073218ab7 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -288,24 +288,24 @@ public void ExecuteDataRowTests_Regular() "NullValueInData (john.doe@example.com,abc123,)", "NullValueInData (john.doe@example.com,abc123,/unit/test)", "NullValue ()", - "OneStringArray (System.String[])", - "TwoStringArrays (System.String[],System.String[])", - "OneObjectArray (System.Object[])", - "TwoObjectArrays (System.Object[],System.Object[])", - "ThreeObjectArrays (System.Object[],System.Object[],System.Object[])", - "FourObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[])", - "FiveObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "SixObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "SevenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "EightObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "NineObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "TenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "ElevenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "TwelveObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "ThirteenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "FourteenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "FifteenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "SixteenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", + "OneStringArray ([])", + "TwoStringArrays ([],[1.4,message])", + "OneObjectArray ([,1])", + "TwoObjectArrays ([,1],[3])", + "ThreeObjectArrays ([1],[2],[3])", + "FourObjectArrays ([1],[2],[3],[4])", + "FiveObjectArrays ([1],[2],[3],[4],[5])", + "SixObjectArrays ([1],[2],[3],[4],[5],[6])", + "SevenObjectArrays ([1],[2],[3],[4],[5],[6],[7])", + "EightObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8])", + "NineObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9])", + "TenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10])", + "ElevenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11])", + "TwelveObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])", + "ThirteenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13])", + "FourteenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14])", + "FifteenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15])", + "SixteenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15],[16])", "MultipleIntegersWrappedWithParams (1,2,3,4,5)"); VerifyE2E.TestsFailed( diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs index a1b16197f0..82483e0bfa 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs @@ -24,9 +24,9 @@ public void TestIdUniqueness_DataRowArray_DefaultStrategy() VerifyE2E.FailedTestCount(testResults, 0); VerifyE2E.TestsPassed( testResults, - "DataRowArraysTests (0,System.Int32[])", - "DataRowArraysTests (0,System.Int32[])", - "DataRowArraysTests (0,System.Int32[])"); + "DataRowArraysTests (0,[])", + "DataRowArraysTests (0,[0])", + "DataRowArraysTests (0,[0,0,0])"); // We cannot assert the expected ID as it is path dependent testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs index 503fa65dfc..461a658b34 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs @@ -24,12 +24,12 @@ public void TestIdUniqueness_DataRowArray_DisplayNameStrategy() VerifyE2E.FailedTestCount(testResults, 0); VerifyE2E.TestsPassed( testResults, - "DataRowArraysTests (0,System.Int32[])", - "DataRowArraysTests (0,System.Int32[])", - "DataRowArraysTests (0,System.Int32[])"); + "DataRowArraysTests (0,[])", + "DataRowArraysTests (0,[0])", + "DataRowArraysTests (0,[0,0,0])"); // We cannot assert the expected ID as it is path dependent - testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); + testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().HaveCount(3); } public void TestIdUniqueness_DataRowString_DisplayNameStrategy() diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs index 00677eb872..2a273ca46a 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs @@ -24,9 +24,9 @@ public void TestIdUniqueness_DataRowArray_FullyQualifiedStrategy() VerifyE2E.FailedTestCount(testResults, 0); VerifyE2E.TestsPassed( testResults, - "DataRowArraysTests (0,System.Int32[])", - "DataRowArraysTests (0,System.Int32[])", - "DataRowArraysTests (0,System.Int32[])"); + "DataRowArraysTests (0,[])", + "DataRowArraysTests (0,[0])", + "DataRowArraysTests (0,[0,0,0])"); // We cannot assert the expected ID as it is path dependent testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs index 4f53cbfdd3..e165643dd4 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs @@ -25,9 +25,9 @@ public void TestIdUniqueness_DataRowArray_LegacyStrategy() VerifyE2E.TestsPassed( testResults, null, // For legacy, there is an extra test result, being the parent and it has no display name - "DataRowArraysTests (0,System.Int32[])", - "DataRowArraysTests (0,System.Int32[])", - "DataRowArraysTests (0,System.Int32[])"); + "DataRowArraysTests (0,[])", + "DataRowArraysTests (0,[0])", + "DataRowArraysTests (0,[0,0,0])"); // We cannot assert the expected ID as it is path dependent testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); diff --git a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs index 9b30f204b5..cc96420e16 100644 --- a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -217,24 +217,24 @@ public void ExecuteRegular_DataRowTests() "NullValueInData (john.doe@example.com,abc123,)", "NullValueInData (john.doe@example.com,abc123,/unit/test)", "NullValue ()", - "OneStringArray (System.String[])", - "TwoStringArrays (System.String[],System.String[])", - "OneObjectArray (System.Object[])", - "TwoObjectArrays (System.Object[],System.Object[])", - "ThreeObjectArrays (System.Object[],System.Object[],System.Object[])", - "FourObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[])", - "FiveObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "SixObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "SevenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "EightObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "NineObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "TenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "ElevenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "TwelveObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "ThirteenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "FourteenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "FifteenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", - "SixteenObjectArrays (System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[],System.Object[])", + "OneStringArray ([])", + "TwoStringArrays ([],[1.4,message])", + "OneObjectArray ([,1])", + "TwoObjectArrays ([,1],[3])", + "ThreeObjectArrays ([1],[2],[3])", + "FourObjectArrays ([1],[2],[3],[4])", + "FiveObjectArrays ([1],[2],[3],[4],[5])", + "SixObjectArrays ([1],[2],[3],[4],[5],[6])", + "SevenObjectArrays ([1],[2],[3],[4],[5],[6],[7])", + "EightObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8])", + "NineObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9])", + "TenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10])", + "ElevenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11])", + "TwelveObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])", + "ThirteenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13])", + "FourteenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14])", + "FifteenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15])", + "SixteenObjectArrays ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15],[16])", "MultipleIntegersWrappedWithParams (1,2,3,4,5)"); ValidateFailedTests( diff --git a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs index b330f51664..b8eebaf6d2 100644 --- a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs @@ -178,6 +178,20 @@ public void GetDisplayNameForMultipleArraysOfMultipleItems() Verify(displayName == "MyMethod ([a,b,c],[1,2,3])"); } + public void GetDisplayNameForMultipleArraysOfMultipleItemsValueTypes() + { + // Arrange + var dataRow = new DataRowAttribute(new[] { 1, 2, 3 }, new[] { 4, 5, 6 }); + var methodInfoMock = new Mock(); + methodInfoMock.SetupGet(x => x.Name).Returns("MyMethod"); + + // Act + string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); + + // Assert + Verify(displayName == "MyMethod ([1,2,3],[4,5,6])"); + } + public void GetDisplayNameForMultipleArraysOfArraysOfMultipleItems() { // Arrange From e6e9fa16df294ea68a2cf8951b0b37fbd7a63228 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Sat, 1 Jun 2024 06:47:02 +0200 Subject: [PATCH 05/17] Improve styling of the method --- .../Attributes/DataSource/DataRowAttribute.cs | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index a32f2b3876..86d8906c4a 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -85,19 +85,26 @@ public DataRowAttribute(params object?[]? data) : data.AsEnumerable(); return string.Format(CultureInfo.CurrentCulture, FrameworkMessages.DataDrivenResultDisplayName, methodInfo.Name, - GetObjectString(displayData)); + string.Join(",", displayData.Select(GetObjectString))); } /// /// Recursively resolve collections of objects to a proper string representation. /// - private static string GetObjectString(IEnumerable enumerable) => - string.Join( - ",", - enumerable.Select(x => - x == null - ? null - : x.GetType().IsArray - ? $"[{GetObjectString(((IEnumerable)x).Cast())}]" - : x.ToString())); + private static string? GetObjectString(object? obj) + { + if (obj == null) + { + return null; + } + + if (!obj.GetType().IsArray) + { + return obj.ToString(); + } + + // We need to box the object here so that we can support value types + IEnumerable boxedObjectEnumerable = ((IEnumerable)obj).Cast(); + return $"[{GetObjectString(boxedObjectEnumerable)}]"; + } } From e439821d26b5496ba59207649cc463f8087d7b99 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Mon, 3 Jun 2024 13:09:51 +0200 Subject: [PATCH 06/17] Fix stackoverflow --- .../TestFramework/Attributes/DataSource/DataRowAttribute.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index 86d8906c4a..80974a1d83 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -105,6 +105,7 @@ public DataRowAttribute(params object?[]? data) // We need to box the object here so that we can support value types IEnumerable boxedObjectEnumerable = ((IEnumerable)obj).Cast(); - return $"[{GetObjectString(boxedObjectEnumerable)}]"; + IEnumerable elementStrings = boxedObjectEnumerable.Select(GetObjectString); + return $"[{string.Join(",", elementStrings)}]"; } } From b27eb45cc2aa1483f931346ede078daa6036146d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Mon, 10 Jun 2024 12:03:24 +0200 Subject: [PATCH 07/17] Avoid need for breaking change --- .../MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs | 4 ++++ .../Attributes/DataSource/DataRowAttribute.cs | 5 ++++- .../TestFramework/PublicAPI/PublicAPI.Unshipped.txt | 1 + .../MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs | 8 ++++---- .../MSTest.IntegrationTests/TestId.LegacyStrategy.cs | 6 +++--- .../Attributes/DataRowAttributeTests.cs | 5 +++++ 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs b/src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs index 43d03cdf6e..37e581b2f3 100644 --- a/src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs +++ b/src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumerator.cs @@ -88,6 +88,10 @@ internal ICollection EnumerateAssembly(string assemblyFileName, TestIdGenerationStrategy testIdGenerationStrategy = assembly.GetCustomAttribute()?.Strategy ?? TestIdGenerationStrategy.FullyQualified; + // Set the test ID generation strategy for the data row attribute so we can improve display name without causing + // a breaking change. + DataRowAttribute.TestIdGenerationStrategy = testIdGenerationStrategy; + TestDataSourceDiscoveryOption testDataSourceDiscovery = assembly.GetCustomAttribute()?.DiscoveryOption #pragma warning disable CS0618 // Type or member is obsolete diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index 80974a1d83..737d2e7f23 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -49,6 +49,8 @@ public DataRowAttribute(params object?[]? data) Data = data ?? [null]; } + protected internal static TestIdGenerationStrategy TestIdGenerationStrategy { get; internal set; } + /// /// Gets data for calling test method. /// @@ -98,7 +100,8 @@ public DataRowAttribute(params object?[]? data) return null; } - if (!obj.GetType().IsArray) + if (TestIdGenerationStrategy != TestIdGenerationStrategy.FullyQualified + || !obj.GetType().IsArray) { return obj.ToString(); } diff --git a/src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt b/src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt index ab058de62d..f3193f4a47 100644 --- a/src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt +++ b/src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt @@ -1 +1,2 @@ #nullable enable +static Microsoft.VisualStudio.TestTools.UnitTesting.DataRowAttribute.TestIdGenerationStrategy.get -> Microsoft.VisualStudio.TestTools.UnitTesting.TestIdGenerationStrategy diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs index 461a658b34..503fa65dfc 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DisplayNameStrategy.cs @@ -24,12 +24,12 @@ public void TestIdUniqueness_DataRowArray_DisplayNameStrategy() VerifyE2E.FailedTestCount(testResults, 0); VerifyE2E.TestsPassed( testResults, - "DataRowArraysTests (0,[])", - "DataRowArraysTests (0,[0])", - "DataRowArraysTests (0,[0,0,0])"); + "DataRowArraysTests (0,System.Int32[])", + "DataRowArraysTests (0,System.Int32[])", + "DataRowArraysTests (0,System.Int32[])"); // We cannot assert the expected ID as it is path dependent - testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().HaveCount(3); + testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); } public void TestIdUniqueness_DataRowString_DisplayNameStrategy() diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs index e165643dd4..4f53cbfdd3 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.LegacyStrategy.cs @@ -25,9 +25,9 @@ public void TestIdUniqueness_DataRowArray_LegacyStrategy() VerifyE2E.TestsPassed( testResults, null, // For legacy, there is an extra test result, being the parent and it has no display name - "DataRowArraysTests (0,[])", - "DataRowArraysTests (0,[0])", - "DataRowArraysTests (0,[0,0,0])"); + "DataRowArraysTests (0,System.Int32[])", + "DataRowArraysTests (0,System.Int32[])", + "DataRowArraysTests (0,System.Int32[])"); // We cannot assert the expected ID as it is path dependent testResults.Select(x => x.TestCase.Id.ToString()).Distinct().Should().ContainSingle(); diff --git a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs index b8eebaf6d2..5a13e56c1b 100644 --- a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs @@ -13,6 +13,11 @@ namespace Microsoft.VisualStudio.TestPlatform.TestFramework.UnitTests.Attributes public class DataRowAttributeTests : TestContainer { + public DataRowAttributeTests() + { + DataRowAttribute.TestIdGenerationStrategy = TestIdGenerationStrategy.FullyQualified; + } + public void DefaultConstructorSetsEmptyArrayPassed() { var dataRow = new DataRowAttribute(); From 689fa0b79d89b32086c1943e9ce61f779bc2f820 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Mon, 10 Jun 2024 13:47:17 +0200 Subject: [PATCH 08/17] Improve display of null and empty string values --- .../Attributes/DataSource/DataRowAttribute.cs | 24 +++++++++++--- .../Parameterized tests/DataRowTests.cs | 31 ++++++++++--------- .../TestId.DefaultStrategy.cs | 4 +-- .../TestId.FullyQualifiedStrategy.cs | 4 +-- .../Parameterized tests/DataRowTests.cs | 28 ++++++++--------- .../Attributes/DataRowAttributeTests.cs | 6 ++-- 6 files changed, 57 insertions(+), 40 deletions(-) diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index 737d2e7f23..701fc453e2 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -13,6 +13,11 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting; [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public class DataRowAttribute : Attribute, ITestDataSource { + /// + /// String inlining for empty string with quotation marks. + /// + private static readonly string EmptyStringWithQuotationMarks = "\"\""; + /// /// Initializes a new instance of the class. /// @@ -95,15 +100,26 @@ public DataRowAttribute(params object?[]? data) /// private static string? GetObjectString(object? obj) { + if (TestIdGenerationStrategy != TestIdGenerationStrategy.FullyQualified) + { + return obj?.ToString(); + } + if (obj == null) { - return null; + return "null"; } - if (TestIdGenerationStrategy != TestIdGenerationStrategy.FullyQualified - || !obj.GetType().IsArray) + if (!obj.GetType().IsArray) { - return obj.ToString(); + string? str = obj.ToString(); + + if (obj is not string) + { + return str; + } + + return string.IsNullOrEmpty(str) ? EmptyStringWithQuotationMarks : str; } // We need to box the object here so that we can support value types diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs index 2073218ab7..06f90dae8c 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -1,4 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. +// // 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; @@ -139,7 +140,7 @@ public void DataRowsShouldSerializeEnumsProperly() // Assert VerifyE2E.TestsPassed( testResults, - "DataRowEnums ()", + "DataRowEnums (null)", "DataRowEnums (Alfa)", "DataRowEnums (Beta)", "DataRowEnums (Gamma)"); @@ -202,35 +203,35 @@ public void ExecuteDataRowTests_Enums() "DataRowEnum_ULong (Alfa)", "DataRowEnum_ULong (Beta)", "DataRowEnum_ULong (Gamma)", - "DataRowEnums_Nullable_SByte ()", + "DataRowEnums_Nullable_SByte (null)", "DataRowEnums_Nullable_SByte (Alfa)", "DataRowEnums_Nullable_SByte (Beta)", "DataRowEnums_Nullable_SByte (Gamma)", - "DataRowEnums_Nullable_Byte ()", + "DataRowEnums_Nullable_Byte (null)", "DataRowEnums_Nullable_Byte (Alfa)", "DataRowEnums_Nullable_Byte (Beta)", "DataRowEnums_Nullable_Byte (Gamma)", - "DataRowEnums_Nullable_Short ()", + "DataRowEnums_Nullable_Short (null)", "DataRowEnums_Nullable_Short (Alfa)", "DataRowEnums_Nullable_Short (Beta)", "DataRowEnums_Nullable_Short (Gamma)", - "DataRowEnums_Nullable_UShort ()", + "DataRowEnums_Nullable_UShort (null)", "DataRowEnums_Nullable_UShort (Alfa)", "DataRowEnums_Nullable_UShort (Beta)", "DataRowEnums_Nullable_UShort (Gamma)", - "DataRowEnums_Nullable_Int ()", + "DataRowEnums_Nullable_Int (null)", "DataRowEnums_Nullable_Int (Alfa)", "DataRowEnums_Nullable_Int (Beta)", "DataRowEnums_Nullable_Int (Gamma)", - "DataRowEnums_Nullable_UInt ()", + "DataRowEnums_Nullable_UInt (null)", "DataRowEnums_Nullable_UInt (Alfa)", "DataRowEnums_Nullable_UInt (Beta)", "DataRowEnums_Nullable_UInt (Gamma)", - "DataRowEnums_Nullable_Long ()", + "DataRowEnums_Nullable_Long (null)", "DataRowEnums_Nullable_Long (Alfa)", "DataRowEnums_Nullable_Long (Beta)", "DataRowEnums_Nullable_Long (Gamma)", - "DataRowEnums_Nullable_ULong ()", + "DataRowEnums_Nullable_ULong (null)", "DataRowEnums_Nullable_ULong (Alfa)", "DataRowEnums_Nullable_ULong (Beta)", "DataRowEnums_Nullable_ULong (Gamma)", @@ -285,13 +286,13 @@ public void ExecuteDataRowTests_Regular() "DataRowTestMixed (2,10,10,10,10,10,10,10,10)", "DataRowTestMixed (3,10,10,10,10,10,10,10,10)", "DataRowTestMixed (4,10,10,10,10,10,10,10,10)", - "NullValueInData (john.doe@example.com,abc123,)", + "NullValueInData (john.doe@example.com,abc123,null)", "NullValueInData (john.doe@example.com,abc123,/unit/test)", - "NullValue ()", - "OneStringArray ([])", - "TwoStringArrays ([],[1.4,message])", - "OneObjectArray ([,1])", - "TwoObjectArrays ([,1],[3])", + "NullValue (null)", + "OneStringArray ([\"\"])", + "TwoStringArrays ([\"\"],[1.4,message])", + "OneObjectArray ([\"\",1])", + "TwoObjectArrays ([\"\",1],[3])", "ThreeObjectArrays ([1],[2],[3])", "FourObjectArrays ([1],[2],[3],[4])", "FiveObjectArrays ([1],[2],[3],[4],[5])", diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs index 82483e0bfa..461710dc6d 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs @@ -45,8 +45,8 @@ public void TestIdUniqueness_DataRowString_DefaultStrategy() VerifyE2E.FailedTestCount(testResults, 0); VerifyE2E.TestsPassed( testResults, - "DataRowStringTests ()", - "DataRowStringTests ()", + "DataRowStringTests (null)", + "DataRowStringTests (\"\")", "DataRowStringTests ( )", "DataRowStringTests ( )"); diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs index 2a273ca46a..819f9e2630 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs @@ -45,8 +45,8 @@ public void TestIdUniqueness_DataRowString_FullyQualifiedStrategy() VerifyE2E.FailedTestCount(testResults, 0); VerifyE2E.TestsPassed( testResults, - "DataRowStringTests ()", - "DataRowStringTests ()", + "DataRowStringTests (null)", + "DataRowStringTests (\"\")", "DataRowStringTests ( )", "DataRowStringTests ( )"); diff --git a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs index cc96420e16..a23fc1f420 100644 --- a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -136,35 +136,35 @@ public void ExecuteDataRowTests_Enums() "DataRowEnum_ULong (Alfa)", "DataRowEnum_ULong (Beta)", "DataRowEnum_ULong (Gamma)", - "DataRowEnums_Nullable_SByte ()", + "DataRowEnums_Nullable_SByte (null)", "DataRowEnums_Nullable_SByte (Alfa)", "DataRowEnums_Nullable_SByte (Beta)", "DataRowEnums_Nullable_SByte (Gamma)", - "DataRowEnums_Nullable_Byte ()", + "DataRowEnums_Nullable_Byte (null)", "DataRowEnums_Nullable_Byte (Alfa)", "DataRowEnums_Nullable_Byte (Beta)", "DataRowEnums_Nullable_Byte (Gamma)", - "DataRowEnums_Nullable_Short ()", + "DataRowEnums_Nullable_Short (null)", "DataRowEnums_Nullable_Short (Alfa)", "DataRowEnums_Nullable_Short (Beta)", "DataRowEnums_Nullable_Short (Gamma)", - "DataRowEnums_Nullable_UShort ()", + "DataRowEnums_Nullable_UShort (null)", "DataRowEnums_Nullable_UShort (Alfa)", "DataRowEnums_Nullable_UShort (Beta)", "DataRowEnums_Nullable_UShort (Gamma)", - "DataRowEnums_Nullable_Int ()", + "DataRowEnums_Nullable_Int (null)", "DataRowEnums_Nullable_Int (Alfa)", "DataRowEnums_Nullable_Int (Beta)", "DataRowEnums_Nullable_Int (Gamma)", - "DataRowEnums_Nullable_UInt ()", + "DataRowEnums_Nullable_UInt (null)", "DataRowEnums_Nullable_UInt (Alfa)", "DataRowEnums_Nullable_UInt (Beta)", "DataRowEnums_Nullable_UInt (Gamma)", - "DataRowEnums_Nullable_Long ()", + "DataRowEnums_Nullable_Long (null)", "DataRowEnums_Nullable_Long (Alfa)", "DataRowEnums_Nullable_Long (Beta)", "DataRowEnums_Nullable_Long (Gamma)", - "DataRowEnums_Nullable_ULong ()", + "DataRowEnums_Nullable_ULong (null)", "DataRowEnums_Nullable_ULong (Alfa)", "DataRowEnums_Nullable_ULong (Beta)", "DataRowEnums_Nullable_ULong (Gamma)", @@ -214,13 +214,13 @@ public void ExecuteRegular_DataRowTests() "DataRowTestMixed (2,10,10,10,10,10,10,10,10)", "DataRowTestMixed (3,10,10,10,10,10,10,10,10)", "DataRowTestMixed (4,10,10,10,10,10,10,10,10)", - "NullValueInData (john.doe@example.com,abc123,)", + "NullValueInData (john.doe@example.com,abc123,null)", "NullValueInData (john.doe@example.com,abc123,/unit/test)", - "NullValue ()", - "OneStringArray ([])", - "TwoStringArrays ([],[1.4,message])", - "OneObjectArray ([,1])", - "TwoObjectArrays ([,1],[3])", + "NullValue (null)", + "OneStringArray ([\"\"])", + "TwoStringArrays ([\"\"],[1.4,message])", + "OneObjectArray ([\"\",1])", + "TwoObjectArrays ([\"\",1],[3])", "ThreeObjectArrays ([1],[2],[3])", "FourObjectArrays ([1],[2],[3],[4])", "FiveObjectArrays ([1],[2],[3],[4],[5])", diff --git a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs index 5a13e56c1b..2620505fd5 100644 --- a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs @@ -89,13 +89,13 @@ public void GetDisplayNameShouldReturnAppropriateName() string[] data2 = ["First", null, "Second"]; string displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data); - Verify(displayName == "DataRowTestMethod (First,Second,)"); + Verify(displayName == "DataRowTestMethod (First,Second,null)"); displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data1); - Verify(displayName == "DataRowTestMethod (,First,Second)"); + Verify(displayName == "DataRowTestMethod (null,First,Second)"); displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data2); - Verify(displayName == "DataRowTestMethod (First,,Second)"); + Verify(displayName == "DataRowTestMethod (First,null,Second)"); } public void GetDisplayNameShouldReturnSpecifiedDisplayName() From de6a41b1a4843627d0630d571920eec2ba23a3ef Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Mon, 10 Jun 2024 13:47:17 +0200 Subject: [PATCH 09/17] Improve display of null and empty string values --- .../Attributes/DataSource/DataRowAttribute.cs | 24 +++++++++++--- .../Parameterized tests/DataRowTests.cs | 31 ++++++++++--------- .../TestId.DefaultStrategy.cs | 4 +-- .../TestId.FullyQualifiedStrategy.cs | 4 +-- .../Parameterized tests/DataRowTests.cs | 28 ++++++++--------- .../Attributes/DataRowAttributeTests.cs | 6 ++-- 6 files changed, 57 insertions(+), 40 deletions(-) diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index 737d2e7f23..701fc453e2 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -13,6 +13,11 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting; [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public class DataRowAttribute : Attribute, ITestDataSource { + /// + /// String inlining for empty string with quotation marks. + /// + private static readonly string EmptyStringWithQuotationMarks = "\"\""; + /// /// Initializes a new instance of the class. /// @@ -95,15 +100,26 @@ public DataRowAttribute(params object?[]? data) /// private static string? GetObjectString(object? obj) { + if (TestIdGenerationStrategy != TestIdGenerationStrategy.FullyQualified) + { + return obj?.ToString(); + } + if (obj == null) { - return null; + return "null"; } - if (TestIdGenerationStrategy != TestIdGenerationStrategy.FullyQualified - || !obj.GetType().IsArray) + if (!obj.GetType().IsArray) { - return obj.ToString(); + string? str = obj.ToString(); + + if (obj is not string) + { + return str; + } + + return string.IsNullOrEmpty(str) ? EmptyStringWithQuotationMarks : str; } // We need to box the object here so that we can support value types diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs index 2073218ab7..06f90dae8c 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -1,4 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. +// // 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; @@ -139,7 +140,7 @@ public void DataRowsShouldSerializeEnumsProperly() // Assert VerifyE2E.TestsPassed( testResults, - "DataRowEnums ()", + "DataRowEnums (null)", "DataRowEnums (Alfa)", "DataRowEnums (Beta)", "DataRowEnums (Gamma)"); @@ -202,35 +203,35 @@ public void ExecuteDataRowTests_Enums() "DataRowEnum_ULong (Alfa)", "DataRowEnum_ULong (Beta)", "DataRowEnum_ULong (Gamma)", - "DataRowEnums_Nullable_SByte ()", + "DataRowEnums_Nullable_SByte (null)", "DataRowEnums_Nullable_SByte (Alfa)", "DataRowEnums_Nullable_SByte (Beta)", "DataRowEnums_Nullable_SByte (Gamma)", - "DataRowEnums_Nullable_Byte ()", + "DataRowEnums_Nullable_Byte (null)", "DataRowEnums_Nullable_Byte (Alfa)", "DataRowEnums_Nullable_Byte (Beta)", "DataRowEnums_Nullable_Byte (Gamma)", - "DataRowEnums_Nullable_Short ()", + "DataRowEnums_Nullable_Short (null)", "DataRowEnums_Nullable_Short (Alfa)", "DataRowEnums_Nullable_Short (Beta)", "DataRowEnums_Nullable_Short (Gamma)", - "DataRowEnums_Nullable_UShort ()", + "DataRowEnums_Nullable_UShort (null)", "DataRowEnums_Nullable_UShort (Alfa)", "DataRowEnums_Nullable_UShort (Beta)", "DataRowEnums_Nullable_UShort (Gamma)", - "DataRowEnums_Nullable_Int ()", + "DataRowEnums_Nullable_Int (null)", "DataRowEnums_Nullable_Int (Alfa)", "DataRowEnums_Nullable_Int (Beta)", "DataRowEnums_Nullable_Int (Gamma)", - "DataRowEnums_Nullable_UInt ()", + "DataRowEnums_Nullable_UInt (null)", "DataRowEnums_Nullable_UInt (Alfa)", "DataRowEnums_Nullable_UInt (Beta)", "DataRowEnums_Nullable_UInt (Gamma)", - "DataRowEnums_Nullable_Long ()", + "DataRowEnums_Nullable_Long (null)", "DataRowEnums_Nullable_Long (Alfa)", "DataRowEnums_Nullable_Long (Beta)", "DataRowEnums_Nullable_Long (Gamma)", - "DataRowEnums_Nullable_ULong ()", + "DataRowEnums_Nullable_ULong (null)", "DataRowEnums_Nullable_ULong (Alfa)", "DataRowEnums_Nullable_ULong (Beta)", "DataRowEnums_Nullable_ULong (Gamma)", @@ -285,13 +286,13 @@ public void ExecuteDataRowTests_Regular() "DataRowTestMixed (2,10,10,10,10,10,10,10,10)", "DataRowTestMixed (3,10,10,10,10,10,10,10,10)", "DataRowTestMixed (4,10,10,10,10,10,10,10,10)", - "NullValueInData (john.doe@example.com,abc123,)", + "NullValueInData (john.doe@example.com,abc123,null)", "NullValueInData (john.doe@example.com,abc123,/unit/test)", - "NullValue ()", - "OneStringArray ([])", - "TwoStringArrays ([],[1.4,message])", - "OneObjectArray ([,1])", - "TwoObjectArrays ([,1],[3])", + "NullValue (null)", + "OneStringArray ([\"\"])", + "TwoStringArrays ([\"\"],[1.4,message])", + "OneObjectArray ([\"\",1])", + "TwoObjectArrays ([\"\",1],[3])", "ThreeObjectArrays ([1],[2],[3])", "FourObjectArrays ([1],[2],[3],[4])", "FiveObjectArrays ([1],[2],[3],[4],[5])", diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs index 82483e0bfa..461710dc6d 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs @@ -45,8 +45,8 @@ public void TestIdUniqueness_DataRowString_DefaultStrategy() VerifyE2E.FailedTestCount(testResults, 0); VerifyE2E.TestsPassed( testResults, - "DataRowStringTests ()", - "DataRowStringTests ()", + "DataRowStringTests (null)", + "DataRowStringTests (\"\")", "DataRowStringTests ( )", "DataRowStringTests ( )"); diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs index 2a273ca46a..819f9e2630 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs @@ -45,8 +45,8 @@ public void TestIdUniqueness_DataRowString_FullyQualifiedStrategy() VerifyE2E.FailedTestCount(testResults, 0); VerifyE2E.TestsPassed( testResults, - "DataRowStringTests ()", - "DataRowStringTests ()", + "DataRowStringTests (null)", + "DataRowStringTests (\"\")", "DataRowStringTests ( )", "DataRowStringTests ( )"); diff --git a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs index cc96420e16..a23fc1f420 100644 --- a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -136,35 +136,35 @@ public void ExecuteDataRowTests_Enums() "DataRowEnum_ULong (Alfa)", "DataRowEnum_ULong (Beta)", "DataRowEnum_ULong (Gamma)", - "DataRowEnums_Nullable_SByte ()", + "DataRowEnums_Nullable_SByte (null)", "DataRowEnums_Nullable_SByte (Alfa)", "DataRowEnums_Nullable_SByte (Beta)", "DataRowEnums_Nullable_SByte (Gamma)", - "DataRowEnums_Nullable_Byte ()", + "DataRowEnums_Nullable_Byte (null)", "DataRowEnums_Nullable_Byte (Alfa)", "DataRowEnums_Nullable_Byte (Beta)", "DataRowEnums_Nullable_Byte (Gamma)", - "DataRowEnums_Nullable_Short ()", + "DataRowEnums_Nullable_Short (null)", "DataRowEnums_Nullable_Short (Alfa)", "DataRowEnums_Nullable_Short (Beta)", "DataRowEnums_Nullable_Short (Gamma)", - "DataRowEnums_Nullable_UShort ()", + "DataRowEnums_Nullable_UShort (null)", "DataRowEnums_Nullable_UShort (Alfa)", "DataRowEnums_Nullable_UShort (Beta)", "DataRowEnums_Nullable_UShort (Gamma)", - "DataRowEnums_Nullable_Int ()", + "DataRowEnums_Nullable_Int (null)", "DataRowEnums_Nullable_Int (Alfa)", "DataRowEnums_Nullable_Int (Beta)", "DataRowEnums_Nullable_Int (Gamma)", - "DataRowEnums_Nullable_UInt ()", + "DataRowEnums_Nullable_UInt (null)", "DataRowEnums_Nullable_UInt (Alfa)", "DataRowEnums_Nullable_UInt (Beta)", "DataRowEnums_Nullable_UInt (Gamma)", - "DataRowEnums_Nullable_Long ()", + "DataRowEnums_Nullable_Long (null)", "DataRowEnums_Nullable_Long (Alfa)", "DataRowEnums_Nullable_Long (Beta)", "DataRowEnums_Nullable_Long (Gamma)", - "DataRowEnums_Nullable_ULong ()", + "DataRowEnums_Nullable_ULong (null)", "DataRowEnums_Nullable_ULong (Alfa)", "DataRowEnums_Nullable_ULong (Beta)", "DataRowEnums_Nullable_ULong (Gamma)", @@ -214,13 +214,13 @@ public void ExecuteRegular_DataRowTests() "DataRowTestMixed (2,10,10,10,10,10,10,10,10)", "DataRowTestMixed (3,10,10,10,10,10,10,10,10)", "DataRowTestMixed (4,10,10,10,10,10,10,10,10)", - "NullValueInData (john.doe@example.com,abc123,)", + "NullValueInData (john.doe@example.com,abc123,null)", "NullValueInData (john.doe@example.com,abc123,/unit/test)", - "NullValue ()", - "OneStringArray ([])", - "TwoStringArrays ([],[1.4,message])", - "OneObjectArray ([,1])", - "TwoObjectArrays ([,1],[3])", + "NullValue (null)", + "OneStringArray ([\"\"])", + "TwoStringArrays ([\"\"],[1.4,message])", + "OneObjectArray ([\"\",1])", + "TwoObjectArrays ([\"\",1],[3])", "ThreeObjectArrays ([1],[2],[3])", "FourObjectArrays ([1],[2],[3],[4])", "FiveObjectArrays ([1],[2],[3],[4],[5])", diff --git a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs index 5a13e56c1b..2620505fd5 100644 --- a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs @@ -89,13 +89,13 @@ public void GetDisplayNameShouldReturnAppropriateName() string[] data2 = ["First", null, "Second"]; string displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data); - Verify(displayName == "DataRowTestMethod (First,Second,)"); + Verify(displayName == "DataRowTestMethod (First,Second,null)"); displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data1); - Verify(displayName == "DataRowTestMethod (,First,Second)"); + Verify(displayName == "DataRowTestMethod (null,First,Second)"); displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data2); - Verify(displayName == "DataRowTestMethod (First,,Second)"); + Verify(displayName == "DataRowTestMethod (First,null,Second)"); } public void GetDisplayNameShouldReturnSpecifiedDisplayName() From 852fe429ef735885941408d1b1663c8a8c67b070 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Mon, 10 Jun 2024 14:39:09 +0200 Subject: [PATCH 10/17] Update src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Amaury Levé --- .../Attributes/DataSource/DataRowAttribute.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index 701fc453e2..4b10eedd4a 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -112,14 +112,12 @@ public DataRowAttribute(params object?[]? data) if (!obj.GetType().IsArray) { - string? str = obj.ToString(); - - if (obj is not string) + if (obj is string s) { - return str; + return string.IsNullOrEmpty(s) ? EmptyStringWithQuotationMarks : s; } - return string.IsNullOrEmpty(str) ? EmptyStringWithQuotationMarks : str; + return obj.ToString(); } // We need to box the object here so that we can support value types From 880b0f96af181177e555fda3d1ee6a5f0177004d Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Mon, 10 Jun 2024 14:51:14 +0200 Subject: [PATCH 11/17] Surround strings with " and chars with ' --- .../Attributes/DataSource/DataRowAttribute.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index 4b10eedd4a..fda7e3de87 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -13,11 +13,6 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting; [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public class DataRowAttribute : Attribute, ITestDataSource { - /// - /// String inlining for empty string with quotation marks. - /// - private static readonly string EmptyStringWithQuotationMarks = "\"\""; - /// /// Initializes a new instance of the class. /// @@ -112,12 +107,12 @@ public DataRowAttribute(params object?[]? data) if (!obj.GetType().IsArray) { - if (obj is string s) + return obj switch { - return string.IsNullOrEmpty(s) ? EmptyStringWithQuotationMarks : s; - } - - return obj.ToString(); + string s => $"\"{s}\"", + char c => $"'{c}'", + _ => obj.ToString() + }; } // We need to box the object here so that we can support value types From f02f12068fe90c04fd1257e9144216af2763db62 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Mon, 10 Jun 2024 15:17:33 +0200 Subject: [PATCH 12/17] Adjust test cases for new string/char rules --- .../Parameterized tests/DataRowTests.cs | 52 +++++++++--------- .../Parameterized tests/DataRowTests.cs | 54 +++++++++---------- .../Attributes/DataRowAttributeTests.cs | 18 +++---- 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs index 06f90dae8c..bd026ebe6e 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -22,11 +22,11 @@ public void ExecuteOnlyDerivedClassDataRowsWhenBothBaseAndDerivedClassHasDataRow // Assert VerifyE2E.TestsPassed( testResults, - "DataRowTestMethod (BaseString1)", - "DataRowTestMethod (BaseString2)", - "DataRowTestMethod (BaseString3)", - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); + "DataRowTestMethod (\"BaseString1\")", + "DataRowTestMethod (\"BaseString2\")", + "DataRowTestMethod (\"BaseString3\")", + "DataRowTestMethod (\"DerivedString1\")", + "DataRowTestMethod (\"DerivedString2\")"); } public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_SimpleDataRows() @@ -41,8 +41,8 @@ public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_Simp // Assert VerifyE2E.TestsPassed( testResults, - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); + "DataRowTestMethod (\"DerivedString1\")", + "DataRowTestMethod (\"DerivedString2\")"); } public void DataRowsExecuteWithRequiredAndOptionalParameters() @@ -58,8 +58,8 @@ public void DataRowsExecuteWithRequiredAndOptionalParameters() VerifyE2E.TestsPassed( testResults, "DataRowTestMethodWithSomeOptionalParameters (123)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString1)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString2,DerivedOptionalString3)"); + "DataRowTestMethodWithSomeOptionalParameters (123,\"DerivedOptionalString1\")", + "DataRowTestMethodWithSomeOptionalParameters (123,\"DerivedOptionalString2\",\"DerivedOptionalString3\")"); } public void DataRowsExecuteWithParamsArrayParameter() @@ -75,9 +75,9 @@ public void DataRowsExecuteWithParamsArrayParameter() VerifyE2E.TestsPassed( testResults, "DataRowTestMethodWithParamsParameters (2)", - "DataRowTestMethodWithParamsParameters (2,DerivedSingleParamsArg)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2,DerivedParamsArg3)"); + "DataRowTestMethodWithParamsParameters (2,\"DerivedSingleParamsArg\")", + "DataRowTestMethodWithParamsParameters (2,\"DerivedParamsArg1\",\"DerivedParamsArg2\")", + "DataRowTestMethodWithParamsParameters (2,\"DerivedParamsArg1\",\"DerivedParamsArg2\",\"DerivedParamsArg3\")"); } public void DataRowsFailWhenInvalidArgumentsProvided() @@ -94,7 +94,7 @@ public void DataRowsFailWhenInvalidArgumentsProvided() testResults, "DataRowTestMethodFailsWithInvalidArguments ()", "DataRowTestMethodFailsWithInvalidArguments (2)", - "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); + "DataRowTestMethodFailsWithInvalidArguments (2,\"DerivedRequiredArgument\",\"DerivedOptionalArgument\",\"DerivedExtraArgument\")"); } public void DataRowsShouldSerializeDoublesProperly() @@ -125,7 +125,7 @@ public void DataRowsShouldSerializeMixedTypesProperly() // Assert VerifyE2E.TestsPassed( testResults, - "DataRowTestMixed (10,10,10,10,10,10,10,10)"); + "DataRowTestMixed (10,10,10,10,10,10,10,\"10\")"); } public void DataRowsShouldSerializeEnumsProperly() @@ -276,21 +276,21 @@ public void ExecuteDataRowTests_Regular() "DataRow1 (20)", "DataRow1 (30)", "DataRow1 (40)", - "DataRow2 (10,String parameter,True,False)", - "DataRow2 (20,String parameter,True,False)", - "DataRow2 (30,String parameter,True,False)", - "DataRow2 (40,String parameter,True,False)", + "DataRow2 (10,\"String parameter\",True,False)", + "DataRow2 (20,\"String parameter\",True,False)", + "DataRow2 (30,\"String parameter\",True,False)", + "DataRow2 (40,\"String parameter\",True,False)", "DataRowTestDouble (10.01,20.01)", "DataRowTestDouble (10.02,20.02)", - "DataRowTestMixed (1,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (2,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (3,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (4,10,10,10,10,10,10,10,10)", - "NullValueInData (john.doe@example.com,abc123,null)", - "NullValueInData (john.doe@example.com,abc123,/unit/test)", + "DataRowTestMixed (1,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (2,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (3,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (4,10,10,10,10,10,10,10,\"10\")", + "NullValueInData (\"john.doe@example.com\",\"abc123\",null)", + "NullValueInData (\"john.doe@example.com\",\"abc123\",\"/unit/test\")", "NullValue (null)", "OneStringArray ([\"\"])", - "TwoStringArrays ([\"\"],[1.4,message])", + "TwoStringArrays ([\"\"],[\"1.4\",\"message\"])", "OneObjectArray ([\"\",1])", "TwoObjectArrays ([\"\",1],[3])", "ThreeObjectArrays ([1],[2],[3])", @@ -313,6 +313,6 @@ public void ExecuteDataRowTests_Regular() testResults, "DataRowTestMethodFailsWithInvalidArguments ()", "DataRowTestMethodFailsWithInvalidArguments (2)", - "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); + "DataRowTestMethodFailsWithInvalidArguments (2,\"DerivedRequiredArgument\",\"DerivedOptionalArgument\",\"DerivedExtraArgument\")"); } } diff --git a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs index a23fc1f420..a5c7d9c0c1 100644 --- a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -14,11 +14,11 @@ public void ExecuteOnlyDerivedClassDataRowsWhenBothBaseAndDerivedClassHasDataRow InvokeVsTestForExecution([TestAssetName], testCaseFilter: "TestCategory~DataRowSimple"); ValidatePassedTestsContain( - "DataRowTestMethod (BaseString1)", - "DataRowTestMethod (BaseString2)", - "DataRowTestMethod (BaseString3)", - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); + "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 @@ -41,8 +41,8 @@ public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_Simp InvokeVsTestForExecution([TestAssetName], testCaseFilter: "FullyQualifiedName~DerivedClass&TestCategory~DataRowSimple"); ValidatePassedTestsContain( - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); + "DataRowTestMethod (\"DerivedString1\")", + "DataRowTestMethod (\"DerivedString2\")"); // 2 tests of DerivedClass.DataRowTestMethod - 2 datarow result and no parent result ValidatePassedTestsCount(2); @@ -54,8 +54,8 @@ public void DataRowsExecuteWithRequiredAndOptionalParameters() ValidatePassedTestsContain( "DataRowTestMethodWithSomeOptionalParameters (123)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString1)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString2,DerivedOptionalString3)"); + "DataRowTestMethodWithSomeOptionalParameters (123,\"DerivedOptionalString1\")", + "DataRowTestMethodWithSomeOptionalParameters (123,\"DerivedOptionalString2\",\"DerivedOptionalString3\")"); // 3 tests of DerivedClass.DataRowTestMethodWithSomeOptionalParameters - 3 datarow result and no parent result ValidatePassedTestsCount(3); @@ -68,8 +68,8 @@ public void DataRowsExecuteWithAllOptionalParameters() ValidatePassedTestsContain( "DataRowTestMethodWithAllOptionalParameters ()", "DataRowTestMethodWithAllOptionalParameters (123)", - "DataRowTestMethodWithAllOptionalParameters (123,DerivedOptionalString4)", - "DataRowTestMethodWithAllOptionalParameters (123,DerivedOptionalString5,DerivedOptionalString6)"); + "DataRowTestMethodWithAllOptionalParameters (123,\"DerivedOptionalString4\")", + "DataRowTestMethodWithAllOptionalParameters (123,\"DerivedOptionalString5\",\"DerivedOptionalString6\")"); // 4 tests of DerivedClass.DataRowTestMethodWithAllOptionalParameters - 4 datarow result and no parent result ValidatePassedTestsCount(4); @@ -81,9 +81,9 @@ public void DataRowsExecuteWithParamsArrayParameter() ValidatePassedTestsContain( "DataRowTestMethodWithParamsParameters (2)", - "DataRowTestMethodWithParamsParameters (2,DerivedSingleParamsArg)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2,DerivedParamsArg3)"); + "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); @@ -97,7 +97,7 @@ public void DataRowsFailWhenInvalidArgumentsProvided() false, "DataRowTestMethodFailsWithInvalidArguments ()", "DataRowTestMethodFailsWithInvalidArguments (2)", - "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); + "DataRowTestMethodFailsWithInvalidArguments (2,\"DerivedRequiredArgument\",\"DerivedOptionalArgument\",\"DerivedExtraArgument\")"); // 3 tests of DerivedClass.DataRowTestMethodFailsWithInvalidArguments - 3 datarow result and no parent result ValidateFailedTestsCount(3); @@ -204,21 +204,21 @@ public void ExecuteRegular_DataRowTests() "DataRow1 (20)", "DataRow1 (30)", "DataRow1 (40)", - "DataRow2 (10,String parameter,True,False)", - "DataRow2 (20,String parameter,True,False)", - "DataRow2 (30,String parameter,True,False)", - "DataRow2 (40,String parameter,True,False)", + "DataRow2 (10,\"String parameter\",True,False)", + "DataRow2 (20,\"String parameter\",True,False)", + "DataRow2 (30,\"String parameter\",True,False)", + "DataRow2 (40,\"String parameter\",True,False)", "DataRowTestDouble (10.01,20.01)", "DataRowTestDouble (10.02,20.02)", - "DataRowTestMixed (1,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (2,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (3,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (4,10,10,10,10,10,10,10,10)", - "NullValueInData (john.doe@example.com,abc123,null)", - "NullValueInData (john.doe@example.com,abc123,/unit/test)", + "DataRowTestMixed (1,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (2,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (3,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (4,10,10,10,10,10,10,10,\"10\")", + "NullValueInData (\"john.doe@example.com\",\"abc123\",null)", + "NullValueInData (\"john.doe@example.com\",\"abc123\",\"/unit/test\")", "NullValue (null)", "OneStringArray ([\"\"])", - "TwoStringArrays ([\"\"],[1.4,message])", + "TwoStringArrays ([\"\"],[\"1.4\",\"message\"])", "OneObjectArray ([\"\",1])", "TwoObjectArrays ([\"\",1],[3])", "ThreeObjectArrays ([1],[2],[3])", @@ -241,6 +241,6 @@ public void ExecuteRegular_DataRowTests() false, "DataRowTestMethodFailsWithInvalidArguments ()", "DataRowTestMethodFailsWithInvalidArguments (2)", - "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); + "DataRowTestMethodFailsWithInvalidArguments (2,\"DerivedRequiredArgument\",\"DerivedOptionalArgument\",\"DerivedExtraArgument\")"); } } diff --git a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs index 2620505fd5..fd6f383bf7 100644 --- a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs @@ -89,13 +89,13 @@ public void GetDisplayNameShouldReturnAppropriateName() string[] data2 = ["First", null, "Second"]; string displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data); - Verify(displayName == "DataRowTestMethod (First,Second,null)"); + Verify(displayName == "DataRowTestMethod (\"First\",\"Second\",null)"); displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data1); - Verify(displayName == "DataRowTestMethod (null,First,Second)"); + Verify(displayName == "DataRowTestMethod (null,\"First\",\"Second\")"); displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data2); - Verify(displayName == "DataRowTestMethod (First,null,Second)"); + Verify(displayName == "DataRowTestMethod (\"First\",null,\"Second\")"); } public void GetDisplayNameShouldReturnSpecifiedDisplayName() @@ -125,7 +125,7 @@ public void GetDisplayNameForArrayOfOneItem() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod ([a])"); + Verify(displayName == "MyMethod ([\"a\"])"); } public void GetDisplayName_AfterOverriding_GetsTheNewDisplayName() @@ -152,7 +152,7 @@ public void GetDisplayNameForArrayOfMultipleItems() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod ([a,b,c])"); + Verify(displayName == "MyMethod ([\"a\",\"b\",\"c\"])"); } public void GetDisplayNameForMultipleArraysOfOneItem() @@ -166,7 +166,7 @@ public void GetDisplayNameForMultipleArraysOfOneItem() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod ([a],[1])"); + Verify(displayName == "MyMethod ([\"a\"],[\"1\"])"); } public void GetDisplayNameForMultipleArraysOfMultipleItems() @@ -180,7 +180,7 @@ public void GetDisplayNameForMultipleArraysOfMultipleItems() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod ([a,b,c],[1,2,3])"); + Verify(displayName == "MyMethod ([\"a\",\"b\",\"c\"],[\"1\",\"2\",\"3\"])"); } public void GetDisplayNameForMultipleArraysOfMultipleItemsValueTypes() @@ -200,7 +200,7 @@ public void GetDisplayNameForMultipleArraysOfMultipleItemsValueTypes() public void GetDisplayNameForMultipleArraysOfArraysOfMultipleItems() { // Arrange - var dataRow = new DataRowAttribute(new[] { new[] { "a", "b", "c" }, new[] { "d", "e", "f" }, new[] { "g", "h", "i" } }, new[] { new[] { "1", "2", "3" }, new[] { "4", "5", "6" }, new[] { "7", "8", "9" } }); + var dataRow = new DataRowAttribute(new[] { new[] { "a", "b", "c" }, new[] { "d", "e", "f" }, new[] { "g", "h", "i" } }, new[] { "kl", "mn", "op" }, new[] { new[] { "1", "2", "3" }, new[] { "4", "5", "6" }, new[] { "7", "8", "9" } }); var methodInfoMock = new Mock(); methodInfoMock.SetupGet(x => x.Name).Returns("MyMethod"); @@ -208,7 +208,7 @@ public void GetDisplayNameForMultipleArraysOfArraysOfMultipleItems() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod ([[a,b,c],[d,e,f],[g,h,i]],[[1,2,3],[4,5,6],[7,8,9]])"); + Verify(displayName == "MyMethod ([[\"a\",\"b\",\"c\"],[\"d\",\"e\",\"f\"],[\"g\",\"h\",\"i\"]],[\"kl\",\"mn\",\"op\"],[[\"1\",\"2\",\"3\"],[\"4\",\"5\",\"6\"],[\"7\",\"8\",\"9\"]])"); } private class DummyDataRowAttribute : DataRowAttribute From c67e4736dba8a452d96c39badd7a06eb6a55927e Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Mon, 10 Jun 2024 15:47:07 +0200 Subject: [PATCH 13/17] Satisfy code analyzer --- .../TestFramework/Attributes/DataSource/DataRowAttribute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index fda7e3de87..969abfad44 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -111,7 +111,7 @@ public DataRowAttribute(params object?[]? data) { string s => $"\"{s}\"", char c => $"'{c}'", - _ => obj.ToString() + _ => obj.ToString(), }; } From a65887c89b03bdfbd65c72977afc4fcd547d3744 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Mon, 10 Jun 2024 16:26:37 +0200 Subject: [PATCH 14/17] Update test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Amaury Levé --- .../MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs index bd026ebe6e..ab245fcaa6 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -1,5 +1,4 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// // 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; From 1d2bc3e384c0360a48a6b1538e8b1ef8620ef937 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Mon, 10 Jun 2024 16:47:53 +0200 Subject: [PATCH 15/17] Improve tests --- .../MSTest.IntegrationTests/TestId.DefaultStrategy.cs | 4 ++-- .../MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs | 4 ++-- .../Execution/TestMethodRunnerTests.cs | 2 +- .../Attributes/DataRowAttributeTests.cs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs index 461710dc6d..a43cc293ed 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs @@ -47,8 +47,8 @@ public void TestIdUniqueness_DataRowString_DefaultStrategy() testResults, "DataRowStringTests (null)", "DataRowStringTests (\"\")", - "DataRowStringTests ( )", - "DataRowStringTests ( )"); + "DataRowStringTests (\" \")", + "DataRowStringTests (\" \")"); // We cannot assert the expected ID as it is path dependent testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs index 819f9e2630..14e9c68444 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs @@ -47,8 +47,8 @@ public void TestIdUniqueness_DataRowString_FullyQualifiedStrategy() testResults, "DataRowStringTests (null)", "DataRowStringTests (\"\")", - "DataRowStringTests ( )", - "DataRowStringTests ( )"); + "DataRowStringTests (\" \")", + "DataRowStringTests (\" \")"); // We cannot assert the expected ID as it is path dependent testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); diff --git a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs index 8c47711976..45c7075390 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs @@ -436,7 +436,7 @@ public void RunTestMethodShouldFillInDisplayNameWithDataRowArgumentsIfNoDisplayN UnitTestResult[] results = testMethodRunner.RunTestMethod(); Verify(results.Length == 1); - Verify(results[0].DisplayName == "DummyTestMethod (2,DummyString)"); + Verify(results[0].DisplayName == "DummyTestMethod (2,\"DummyString\")"); } public void RunTestMethodShouldSetResultFilesIfPresentForDataDrivenTests() diff --git a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs index fd6f383bf7..9a9bfd1c7f 100644 --- a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs @@ -200,7 +200,7 @@ public void GetDisplayNameForMultipleArraysOfMultipleItemsValueTypes() public void GetDisplayNameForMultipleArraysOfArraysOfMultipleItems() { // Arrange - var dataRow = new DataRowAttribute(new[] { new[] { "a", "b", "c" }, new[] { "d", "e", "f" }, new[] { "g", "h", "i" } }, new[] { "kl", "mn", "op" }, new[] { new[] { "1", "2", "3" }, new[] { "4", "5", "6" }, new[] { "7", "8", "9" } }); + var dataRow = new DataRowAttribute(new[] { new[] { "a", "b", "c" }, new[] { "d", "e", "f" }, new[] { "gh", "ij", "kl" } }, new[] { 'm', 'n', 'o' }, new[] { new[] { "1", "2", "3" }, new[] { "4", "5", "6" }, new[] { "7", "8", "9" } }); var methodInfoMock = new Mock(); methodInfoMock.SetupGet(x => x.Name).Returns("MyMethod"); @@ -208,7 +208,7 @@ public void GetDisplayNameForMultipleArraysOfArraysOfMultipleItems() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod ([[\"a\",\"b\",\"c\"],[\"d\",\"e\",\"f\"],[\"g\",\"h\",\"i\"]],[\"kl\",\"mn\",\"op\"],[[\"1\",\"2\",\"3\"],[\"4\",\"5\",\"6\"],[\"7\",\"8\",\"9\"]])"); + Verify(displayName == "MyMethod ([[\"a\",\"b\",\"c\"],[\"d\",\"e\",\"f\"],[\"gh\",\"ij\",\"kl\"]],['m','n','o'],[[\"1\",\"2\",\"3\"],[\"4\",\"5\",\"6\"],[\"7\",\"8\",\"9\"]])"); } private class DummyDataRowAttribute : DataRowAttribute From 8ed5759283efe819cf1f342e8ed2ffc86b63cb3b Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Mon, 10 Jun 2024 17:11:03 +0200 Subject: [PATCH 16/17] Fix some more integration tests --- .../MSTest.IntegrationTests/ClsTests.cs | 6 +++--- .../DataExtensibilityTests.cs | 18 +++++++++--------- .../DataExtensibilityTests.cs | 18 +++++++++--------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs index 919aff6141..042cf09853 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs @@ -25,8 +25,8 @@ public void TestsAreRun() testResults, "TestMethod", "IntDataRow (10)", - "StringDataRow (some string)", - "StringDataRow2 (some string)", - "StringDataRow2 (some other string)"); + "StringDataRow (\"some string\")", + "StringDataRow2 (\"some string\")", + "StringDataRow2 (\"some other string\")"); } } diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs index acc04e2ce3..a4d813b64f 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs @@ -81,17 +81,17 @@ public void ExecuteCustomTestExtensibilityWithTestDataTests() // Assert VerifyE2E.TestsPassed( testResults, - "CustomTestMethod2 (B)", - "CustomTestMethod2 (B)", - "CustomTestMethod2 (B)"); + "CustomTestMethod2 (\"B\")", + "CustomTestMethod2 (\"B\")", + "CustomTestMethod2 (\"B\")"); VerifyE2E.TestsFailed( testResults, - "CustomTestMethod2 (A)", - "CustomTestMethod2 (A)", - "CustomTestMethod2 (A)", - "CustomTestMethod2 (C)", - "CustomTestMethod2 (C)", - "CustomTestMethod2 (C)"); + "CustomTestMethod2 (\"A)\"", + "CustomTestMethod2 (\"A\")", + "CustomTestMethod2 (\"A\")", + "CustomTestMethod2 (\"C\")", + "CustomTestMethod2 (\"C\")", + "CustomTestMethod2 (\"C\")"); } } diff --git a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs index 78c3dde3e1..4d25cc9a15 100644 --- a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs +++ b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs @@ -65,17 +65,17 @@ public void ExecuteCustomTestExtensibilityWithTestDataTests() InvokeVsTestForExecution([TestAssetName], testCaseFilter: "FullyQualifiedName~CustomTestExTests.CustomTestMethod2"); ValidatePassedTests( - "CustomTestMethod2 (B)", - "CustomTestMethod2 (B)", - "CustomTestMethod2 (B)"); + "CustomTestMethod2 (\"B\")", + "CustomTestMethod2 (\"B\")", + "CustomTestMethod2 (\"B\")"); ValidateFailedTestsCount(6); ValidateFailedTestsContain( true, - "CustomTestMethod2 (A)", - "CustomTestMethod2 (A)", - "CustomTestMethod2 (A)", - "CustomTestMethod2 (C)", - "CustomTestMethod2 (C)", - "CustomTestMethod2 (C)"); + "CustomTestMethod2 (\"A\")", + "CustomTestMethod2 (\"A\")", + "CustomTestMethod2 (\"A\")", + "CustomTestMethod2 (\"C\")", + "CustomTestMethod2 (\"C\")", + "CustomTestMethod2 (\"C\")"); } } From 7c9ef89af43febf7f5006c11c32889d8ca69ee2a Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Mon, 10 Jun 2024 17:12:39 +0200 Subject: [PATCH 17/17] Fix test --- .../Parameterized tests/DataExtensibilityTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs index a4d813b64f..e36a2f78ef 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs @@ -87,7 +87,7 @@ public void ExecuteCustomTestExtensibilityWithTestDataTests() VerifyE2E.TestsFailed( testResults, - "CustomTestMethod2 (\"A)\"", + "CustomTestMethod2 (\"A\")", "CustomTestMethod2 (\"A\")", "CustomTestMethod2 (\"A\")", "CustomTestMethod2 (\"C\")",