Skip to content

dotnet test --filter FullyQualifiedName fails to work with parameterized test cases #13963

@yshpakov

Description

@yshpakov

Using NUnit 3.12.0,

Trying to run something like this:

        private static IEnumerable<object[]> LoginAsGuestSource()
        {
            yield return new object[] {5};
        }

        [Test]
        [TestCaseSource(nameof(LoginAsGuestSource))]
        public void LoginAsGuest(int i)
        {
... ... ...
... ... ...
... ... ...
        }

When I specify full test case name without parameters like:
dotnet test --filter "FullyQualifiedName=MyNamespace.MyTestClass.LoginAsGuest"
it throws an error:
No test matches the given testcase filter FullyQualifiedName=MyNamespace.MyTestClass.LoginAsGuestin C:\MyTestsProject\bin\Debug\netcoreapp2.2\MyTestAssembly.dll
When I specify parameters (no matter escaped or not):

dotnet test --filter "FullyQualifiedName=MyNamespace.MyTestClass.LoginAsGuest(5)"
dotnet test --filter "FullyQualifiedName=MyNamespace.MyTestClass.LoginAsGuest%285%29"

it throws an error:

An exception occurred while invoking executor 'executor://nunit3testexecutor/': Incorrect format for TestCaseFilter Missing Operator '|' or '&'. Specify the correct format and try again. Note that the incorrect format can lead to no test getting executed.

Test Run Failed.

When I remove both parameter for that method and TestCaseSource attribute, it runs successfully.

Adding .runsettings into command line doesn't work either:
dotnet test --filter "FullyQualifiedName=MyNamespace.MyTestClass.LoginAsGuest" -s mySettings.runsettings

mySettings.runsettings:

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <!-- Parameters used by tests at runtime -->
  <TestRunParameters>
    <Parameter name="i" value="5" />
  </TestRunParameters>
</RunSettings>

Did I miss something in documentation or it's an existing limitation of .NET Core? If so, can it be added into the documentation as a limitation. Or there is another way how to specify test case parameters or escape ones?

edit by @mairaw: added document details


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cli/subsvcneeds-more-infoNeeds more info from OP. Auto-closed after 2 weeks if no response. [org][resolution]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions