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.

Incorrect format for TestCaseFilter Error: Missing '('

See original GitHub issue

Environment

  • 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:closed
  • Created 4 years ago
  • Reactions:16
  • Comments:33 (10 by maintainers)

github_iconTop GitHub Comments

5reactions
igabeszcommented, Jun 18, 2020

A workaround for fellow developers / testers who just want to make the tests run again: Wrap your test case data in a TestCaseData object, and return with an IEnumerable<TestCaseData> instead of an IEnumerable<object[]>. Fill the TestName of each of these cases; avoid special characters, and “tadaa” the tests will run again properly.

// Still looking forward to a proper fix though.

2reactions
redwyrecommented, Nov 14, 2021

I’m getting this error with the latest packages (for vs2019) running in vs 2022:

========== Starting test run ==========
Incorrect format for TestCaseFilter Error: Missing '('. Specify the correct format and try again. Note that the incorrect format can lead to no test getting executed.
NUnit Adapter 4.1.0.0: Test execution started
An exception occurred while invoking executor 'executor://nunit3testexecutor/': Incorrect format for TestCaseFilter Error: Missing '('. Specify the correct format and try again. Note that the incorrect format can lead to no test getting executed.
Stack trace:
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery.DiscoveryContext.GetTestCaseFilter(IEnumerable`1 supportedProperties, Func`2 propertyProvider)
   at NUnit.VisualStudio.TestAdapter.VsTestFilter.get_TfsTestCaseFilterExpression() in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\VsTestFilter.cs:line 100
   at NUnit.VisualStudio.TestAdapter.VsTestFilter.get_IsEmpty() in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\VsTestFilter.cs:line 102
   at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.InitializeForExecution(IRunContext runContext, IFrameworkHandle frameworkHandle) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestExecutor.cs:line 248
   at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunTests(IEnumerable`1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestExecutor.cs:line 105
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.RunTestsWithSources.InvokeExecutor(LazyExtension`2 executor, Tuple`2 executorUriExtensionTuple, RunContext runContext, IFrameworkHandle frameworkHandle)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.RunTestInternalWithExecutors(IEnumerable`1 executorUriExtensionMap, Int64 totalTests)

========== Test run finished: 0 Tests (0 Passed, 0 Failed, 0 Skipped) run in 131 ms ==========

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 TestCaseData and 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.

Read more comments on GitHub >

github_iconTop 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 >

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