Incorrect format for TestCaseFilter Error: Missing '('
See original GitHub issueEnvironment
- NUnit 3.12
- NUnit Adapter 3.16
- VS Professional 2019 Version 16.4.2
- .NET Framework 4.7.2
Description When executing a category of tests (e.g. Run All), if a test is included in the list of tests that contains an escaped double quote followed by a closing parenthesis, the following error may occur and the test run will fail:
An exception occurred while invoking executor ‘executor://nunit3testexecutor/’: Incorrect format for TestCaseFilter Error: Missing ‘(’.
Note There are a number of recently closed issues (thanks 😃 ) that are similar regarding braces or quotes in the test case name or arguments, but this is not quite the same (esp. since it breaks despite resolution of the other issues)
Reproduction Run this code, and examine the Test Output window to see the exception as per above.
public class Tests
{
[TestCase("Works fine", ")")]
[TestCase("Works fine", "()")]
[TestCase("Works fine", "(")]
[TestCase("Works fine", "\"(")]
[TestCase("Works fine", ")\"")]
[TestCase("Works fine", "(\"")]
[TestCase("Works fine", "()\"")]
[TestCase("Breaks test executor when using Run All", "\"()")]
[TestCase("Breaks test executor when using Run All", "\")")]
public void TestName(string expectedBehaviour, string data)
{
//Irrelevant
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:16
- Comments:33 (10 by maintainers)
Top Results From Across the Web
Unable to run tests: Incorrect format for TestCaseFilter Error
Creating an xunit theory test with the following format appears to break Visual Studio test hierarchy such that tests cannot be executed.
Read more >c# - Cannot run all tests in visual studio. Incorrect format for ...
Incorrect format for TestCaseFilter Missing Operator '|' or '&' The following is error info. I changed real method name and application name to ......
Read more >.NET NUnit Parallel Tests: Incorrect format for TestCaseFilter ...
I'm going to investigate this issue soon. I believe the problem relates to how parametrized test classes (not tests themselves) render into the...
Read more >Dotnet test: TestCaseFilter cropped because of CMD ...
An exception occurred while invoking executor 'executor://nunit3testexecutor/': Incorrect format for TestCaseFilter Missing Operator '|' or '&'. Specify the ...
Read more >Solving Long, flaky testing with Azure DevOps - Tsuyoshi Ushio
Incorrect format for TestCaseFilter Missing Operator '|' or '&'. Specify the correct format and try again. Note that the incorrect format can ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

A workaround for fellow developers / testers who just want to make the tests run again: Wrap your test case data in a
TestCaseDataobject, and return with anIEnumerable<TestCaseData>instead of anIEnumerable<object[]>. Fill theTestNameof each of these cases; avoid special characters, and “tadaa” the tests will run again properly.// Still looking forward to a proper fix though.
I’m getting this error with the latest packages (for vs2019) running in vs 2022:
I’ve created a gist with the relevant files I can think of: https://gist.github.com/redwyre/0fb0c9f177af278f76aa8cf49c1eb1dc
It seems like NUnit is just calling ToString() on all the parameters to make the test name, and in some cases it doesn’t work properly with more complex objects.
I think I can work around this by wrapping each record in
TestCaseDataand name them, but it overrides the full name of the test not just the postfix. I’m not very experienced with NUnit myself so not sure if there is a better way.