From 0e1051556985dddbacfccff2996cdc0119928150 Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Mon, 6 Sep 2021 12:01:08 +0200 Subject: [PATCH] #724 comments fixed. --- .gitignore | 1 - .../Execution/TestAssemblySettingsProvider.cs | 1 - .../Extensions/TestCaseExtensions.cs | 1 + src/Adapter/MSTest.CoreAdapter/MSTestSettings.cs | 12 +++++++++--- src/TestFramework/Extension.UWP/Extension.UWP.csproj | 4 ++-- .../MSTest.Core/Attributes/ClassCleanupLifecycle.cs | 2 +- .../Attributes/ClassCleanupSequencingAttribute.cs | 4 ++-- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 3f4955fb4d..7ef5c066f7 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,6 @@ .vs/ .vscode/ *.cache -.idea/ # Build results [Bb]in/ diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TestAssemblySettingsProvider.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TestAssemblySettingsProvider.cs index 28b5940427..39961cb5f2 100644 --- a/src/Adapter/MSTest.CoreAdapter/Execution/TestAssemblySettingsProvider.cs +++ b/src/Adapter/MSTest.CoreAdapter/Execution/TestAssemblySettingsProvider.cs @@ -58,7 +58,6 @@ internal TestAssemblySettings GetSettings(string source) testAssemblySettings.CanParallelizeAssembly = !this.reflectHelper.IsDoNotParallelizeSet(testAssembly); var classCleanupSequencingAttribute = this.reflectHelper.GetClassCleanupAttribute(testAssembly); - if (classCleanupSequencingAttribute != null) { testAssemblySettings.ClassCleanupLifecycle = classCleanupSequencingAttribute.LifecyclePosition; diff --git a/src/Adapter/MSTest.CoreAdapter/Extensions/TestCaseExtensions.cs b/src/Adapter/MSTest.CoreAdapter/Extensions/TestCaseExtensions.cs index 27e1640e35..4b86857b87 100644 --- a/src/Adapter/MSTest.CoreAdapter/Extensions/TestCaseExtensions.cs +++ b/src/Adapter/MSTest.CoreAdapter/Extensions/TestCaseExtensions.cs @@ -61,6 +61,7 @@ internal static string GetTestName(this TestCase testCase, string testClassName) var name = fullyQualifiedName.StartsWith($"{testClassName}.") ? fullyQualifiedName.Remove(0, $"{testClassName}.".Length) : fullyQualifiedName; + return name; } diff --git a/src/Adapter/MSTest.CoreAdapter/MSTestSettings.cs b/src/Adapter/MSTest.CoreAdapter/MSTestSettings.cs index 739c8eb6b2..17ff3dfc93 100644 --- a/src/Adapter/MSTest.CoreAdapter/MSTestSettings.cs +++ b/src/Adapter/MSTest.CoreAdapter/MSTestSettings.cs @@ -365,7 +365,7 @@ private static MSTestSettings ToSettings(XmlReader reader) case "CLASSCLEANUPLIFECYCLE": { var value = reader.ReadInnerXml(); - if (Enum.TryParse(value, out ClassCleanupLifecycle lifecycle)) + if (TryParseEnum(value, out ClassCleanupLifecycle lifecycle)) { settings.ClassCleanupLifecycle = lifecycle; } @@ -374,7 +374,7 @@ private static MSTestSettings ToSettings(XmlReader reader) throw new AdapterSettingsException( string.Format( CultureInfo.CurrentCulture, - Resource.InvalidParallelScopeValue, + Resource.InvalidClassCleanupLifecycleValue, value, string.Join(", ", Enum.GetNames(typeof(ClassCleanupLifecycle))))); } @@ -516,7 +516,7 @@ private static void SetParallelSettings(XmlReader reader, MSTestSettings setting case "SCOPE": { var value = reader.ReadInnerXml(); - if (Enum.TryParse(value, out ExecutionScope scope)) + if (TryParseEnum(value, out ExecutionScope scope)) { settings.ParallelizationScope = scope; } @@ -558,6 +558,12 @@ private static void SetParallelSettings(XmlReader reader, MSTestSettings setting } } + private static bool TryParseEnum(string value, out T result) + where T : struct, Enum + { + return Enum.TryParse(value, true, out result) && Enum.IsDefined(typeof(T), result); + } + private static void SetGlobalSettings(string runsettingsXml, MSTestSettings settings) { var runconfigElement = XDocument.Parse(runsettingsXml)?.Element("RunSettings")?.Element("RunConfiguration"); diff --git a/src/TestFramework/Extension.UWP/Extension.UWP.csproj b/src/TestFramework/Extension.UWP/Extension.UWP.csproj index 6419d8e0bd..6393c1db17 100644 --- a/src/TestFramework/Extension.UWP/Extension.UWP.csproj +++ b/src/TestFramework/Extension.UWP/Extension.UWP.csproj @@ -11,8 +11,8 @@ en-US win10-arm;win10-arm-aot;win10-x86;win10-x86-aot;win10-x64;win10-x64-aot UAP - 10.0.18362.0 - 10.0.18362.0 + 10.0.14393.0 + 10.0.10240.0 15 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} diff --git a/src/TestFramework/MSTest.Core/Attributes/ClassCleanupLifecycle.cs b/src/TestFramework/MSTest.Core/Attributes/ClassCleanupLifecycle.cs index fef6085ec1..314911e912 100644 --- a/src/TestFramework/MSTest.Core/Attributes/ClassCleanupLifecycle.cs +++ b/src/TestFramework/MSTest.Core/Attributes/ClassCleanupLifecycle.cs @@ -4,7 +4,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting { /// - /// Where during test lifecycle should ClassCleanup happen + /// When to run ClassCleanup during test execution /// public enum ClassCleanupLifecycle { diff --git a/src/TestFramework/MSTest.Core/Attributes/ClassCleanupSequencingAttribute.cs b/src/TestFramework/MSTest.Core/Attributes/ClassCleanupSequencingAttribute.cs index 6f51d4ad66..4d9bf1230c 100644 --- a/src/TestFramework/MSTest.Core/Attributes/ClassCleanupSequencingAttribute.cs +++ b/src/TestFramework/MSTest.Core/Attributes/ClassCleanupSequencingAttribute.cs @@ -6,7 +6,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting using System; /// - /// Specification for parallelization level for a test run. + /// Specification for when to run class cleanup methods. /// [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public class ClassCleanupSequencingAttribute : Attribute @@ -22,7 +22,7 @@ public ClassCleanupSequencingAttribute() } /// - /// Gets or sets the number of workers to be used for the parallel run. + /// Gets or sets when to run class cleanup methods. /// public ClassCleanupLifecycle LifecyclePosition {