nunit3-vs-adapter: An exception occurred while invoking executor 'executor://nunit3testexecutor/': Incorrect format for TestCaseFilter Error: Missing ')'.

ENVIRONMENT


NUnit: 3.10.1 NUnit3TestAdapter: 3.10.0 Visual Studio: 15.9.2 .NET Platform: .NET Core 2.1

DESCRIPTION


When executing a category of tests, if a test is included in the list of tests that contains an opening parenthesis, but does not contain the 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 ‘)’. Specify the correct format and try again. Note that the incorrect format can lead to no test getting executed.

REPRODUCTION


This issue can only be reproduced when selecting a group of tests to run - selecting individual tests, or selecting ‘Run All’ will no reproduce the issue.

It appears that reproducing the issue requires there to be a test that includes an opening parenthesis but does not include a closing parenthesis, and a test that ends with the closing bracket character (‘]’).

You should be able to reproduce the issue by using the following test code:

public class TestNameRepro
{
    #region TestCaseSource

    protected static IEnumerable TestName_TestCases
    {
        get
        {
            // Adding a parenthesis to the end of this test name will stop the exception from throwing (e.g. $"TestName(...)")
            yield return new TestCaseData(1).SetName($"TestName(...");

            // Cannot be duplicated without a second test included that ends with a ']'
            yield return new TestCaseData(2).SetName($"TestName(...)]");
        }
    }

    #endregion     
    [Test, TestCaseSource(nameof(TestName_TestCases))]
    public void TestName(int input)
    {
        // Irrelevant  
    }
}

Once built, categorize the test explorer using the ‘Class’ category selection, and select the test suite ‘TestNameRepro’ and click ‘Run Selected Tests’: image

The ‘Tests’ output window should display the error mentioned above:

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.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 30 (14 by maintainers)

Most upvoted comments

As an update to this, I tested the fix with the 3.16.0-dev-01202 package and this Test is not run with the same error message as described in this issue.

Error] 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.

public class TupleUnitTests
{
	[Test]
	[TestCase(typeof(IDummy<(String body, Dictionary<String, String> applicationData), String>))]
	public void UnitTest_TestCaseWithTuple_TestIsNotExecuted(Type targetType)
	{
		Assert.That(targetType, Is.Not.Null);
	}
}

public interface IDummy<T1, T2> : IList<T1> { }

If I however switch around the Types, then it will execute [TestCase(typeof(IDummy<String, (String body, Dictionary<String, String> applicationData)>))]

Summary: TestCase[Type<Tuple(), Type>] Error TestCase[Type<Type, Tuple()>] Executed

Happened to me on VS2022. Fixed it by removing the “{m}” modifier inside of the property TestName.