-
Notifications
You must be signed in to change notification settings - Fork 341
Description
https://github.com/Microsoft/vstest/blob/main/docs/RunSettingsArguments.md mentions that the way to pass test parameters at the dotnet test command line is to use "TestRunParameters.Parameter(name=\"...", value=\"...\")" parameters after --.
It would be helpful to include instructions on what to do if semicolons in the test parameter value are getting replaced with spaces when accessed by the test. What's going on is that VSTestTask2.VSTestCLIRunSettings is a string[] property, and so the input to it is split on any ;.
The fix is to replace ; with %3B at the command line inside the test parameter value.
This is no fun when generating connection strings dynamically in build scripts. If there's any possibility of allowing this scenario to "just work" so that people don't have to use %3B at the command line inside their test parameter values, that would be awesome. Otherwise, docs on this would really help.
Example
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.2.0" />
</ItemGroup>
</Project>using NUnit.Framework;
public class Tests
{
[Test]
public void Repro()
{
Assert.That(TestContext.Parameters["connectionString"], Is.EqualTo("A=B;C=D"));
}
}In cmd.exe:
dotnet test -- "TestRunParameters.Parameter(name=\"connectionString\", value=\"A=B;C=D\")":
String lengths are both 7. Strings differ at index 3.
Expected: "A=B;C=D"
But was: "A=B C=D"
--------------^
To get the test to pass, use %3B at the command line:
dotnet test -- "TestRunParameters.Parameter(name=\"connectionString\", value=\"A=B%3BC=D\")":