diff --git a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs
index 99f6909bdd..c6e981289d 100644
--- a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs
+++ b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs
@@ -95,7 +95,7 @@ public static void UpdateRunSettingsNode(this IRunSettingsProvider runSettingsPr
///
public static Match GetTestRunParameterNodeMatch(this IRunSettingsProvider runSettingsProvider, string node)
{
- var attrName = $"(?<{AttributeNameString}>\\w+)";
+ var attrName = $"(?<{AttributeNameString}>[\\w.:-]+)";
var attrValue = $"(?<{AttributeValueString}>.+)";
Regex regex = new Regex($"{Constants.TestRunParametersName}.{ParameterString}\\(name\\s*=\\s*\"{attrName}\"\\s*,\\s*value\\s*=\\s*\"{attrValue}\"\\)");
Match match = regex.Match(node);
diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/RunSettingsProviderExtensionsTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/RunSettingsProviderExtensionsTests.cs
index 82e834be78..ffb741dbed 100644
--- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/RunSettingsProviderExtensionsTests.cs
+++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/RunSettingsProviderExtensionsTests.cs
@@ -134,13 +134,7 @@ public void UpdateRunSettingsNodeShouldAddNewKeyIfNotPresent()
[TestMethod]
public void UpdateTestRunParameterSettingsNodeShouldAddNewKeyIfNotPresent()
{
- var match = this.runSettingsProvider.GetTestRunParameterNodeMatch("TestRunParameters.Parameter(name=\"weburl\",value=\"http://localhost//abc\")");
- var runSettingsWithTestRunParameters = "\r\n\r\n \r\n \r\n \r\n";
-
- this.runSettingsProvider.UpdateRunSettings("\r\n ");
- this.runSettingsProvider.UpdateTestRunParameterSettingsNode(match);
-
- Assert.AreEqual(runSettingsWithTestRunParameters, this.runSettingsProvider.ActiveRunSettings.SettingsXml);
+ this.CheckRunSettingsAreUpdated("weburl", @"http://localhost//abc");
}
[TestMethod]
@@ -156,6 +150,24 @@ public void UpdateTetsRunParameterSettingsNodeShouldOverrideValueIfKeyIsAlreadyP
Assert.AreEqual(runSettingsWithTestRunParametersOverrode, this.runSettingsProvider.ActiveRunSettings.SettingsXml);
}
+ [TestMethod]
+ public void TestRunParameterSettingsNodeCanContainSpecialCharacters()
+ {
+ this.CheckRunSettingsAreUpdated("weburl:name", @"http://localhost//abc");
+ }
+
+ [TestMethod]
+ public void TestRunParameterSettingsNodeCanBeJustASingleCharacter()
+ {
+ this.CheckRunSettingsAreUpdated("a", @"http://localhost//abc");
+ }
+
+ [TestMethod]
+ public void TestRunParameterSettingsNodeCanMixSpecialCharacters()
+ {
+ this.CheckRunSettingsAreUpdated("___this_Should:be-valid.2", @"http://localhost//abc");
+ }
+
[TestMethod]
public void UpdateRunSettingsNodeShouldUpdateKeyIfAlreadyPresent()
{
@@ -230,6 +242,25 @@ public void QueryRunSettingsNodeShouldReturnCorrectValue()
Assert.AreEqual("x86", this.runSettingsProvider.QueryRunSettingsNode("RunConfiguration.TargetPlatform"));
}
+ private void CheckRunSettingsAreUpdated(string parameterName, string parameterValue)
+ {
+ var match = this.runSettingsProvider.GetTestRunParameterNodeMatch(
+ $@"TestRunParameters.Parameter(name=""{parameterName}"",value=""{parameterValue}"")");
+ var runSettingsWithTestRunParameters = string.Join(
+ Environment.NewLine,
+ $@"",
+ $@"",
+ $@" ",
+ $@" ",
+ $@" ",
+ $@"");
+
+ this.runSettingsProvider.UpdateRunSettings("\r\n ");
+ this.runSettingsProvider.UpdateTestRunParameterSettingsNode(match);
+
+ Assert.AreEqual(runSettingsWithTestRunParameters, this.runSettingsProvider.ActiveRunSettings.SettingsXml);
+ }
+
private class TestableRunSettingsProvider : IRunSettingsProvider
{
public RunSettings ActiveRunSettings