question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet test should escape MSBuild special characters in filter

See original GitHub issue

Inspired by @yshpakov’s dotnet/docs#13749.

dotnet test accepts a --filter option that is passed as a property on the MSBuild command line:

https://github.com/dotnet/cli/blob/cb38255c64ba0d17b06aac725c4a86ea24d79aac/src/dotnet/commands/dotnet-test/TestCommandParser.cs#L34-L39

Unfortunately, there are some test case names that use MSBuild special characters, like , (%2C). These should be escaped by the test command rather than passing the need to escape up to the user.

Repro steps and workaround:

$ dotnet new mstest
...
$  dotnet test --filter "FullyQualifiedName=MyNamespace.MyTestsClass<ParameterType1,ParameterType2>.MyTestMethod"
MSBUILD : error MSB1006: Property is not valid.
Switch: ParameterType2>.MyTestMethod

For switch syntax, type "MSBuild -help"
$ dotnet test --filter "FullyQualifiedName=MyNamespace.MyTestsClass<ParameterType1%2CParameterType2>.MyTestMethod"
Test run for S:\repro\dotnet\docs\issues\13749\bin\Debug\netcoreapp3.0\13749.dll(.NETCoreApp,Version=v3.0)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0-preview-20190808-04
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

A total of 1 test files matched the specified pattern.
No test matches the given testcase filter `FullyQualifiedName=MyNamespace.MyTestsClass<ParameterType1,ParameterType2>.MyTestMethod` in S:\repro\dotnet\docs\issues\13749\bin\Debug\netcoreapp3.0\13749.dll

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
fscottmillercommented, Feb 7, 2022

This is phenomenal! Thank you so much. Looking forward to trying it out 😃

1reaction
yshpakovcommented, Aug 19, 2019

To me now it looks like a bug and the documentation doesn’t have a reference to MSBuild in general or to MSBuild escaping rules. At least maybe the documentation needs to be updated now:

https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test?tabs=netcore21

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run selected unit tests - .NET
With the dotnet test command in .NET Core, you can use a filter expression to run selected tests. This article demonstrates how to...
Read more >
How to escape quotes in dotnet test --filter
I'd like to run tests from commandline using dotnet test --filter , I have tests with fully qualified name similar to: Namespace.
Read more >
Coverage Analysis from the Command Line - dotCover
Analyze unit tests coverage in .NET Framework projects · Make sure your unit test project is built. · Navigate to the directory where...
Read more >
coverlet.console 1.0.0
Coverlet is a cross platform code coverage tool for .NET Core, with support for line, branch and method coverage.
Read more >
Bookshop Example
With SpecFlow+ Runner the Name and TestCategory properties can be used to filter the acceptance tests. Tip: You can list all acceptance tests...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found