Skip to content

NUnit3TestAdapter 6.3.1: [TestCase] with enum parameter appears twice in Visual Studio Test Explorer (MTP) #1513

Closed

Description

@tom-englert

Possibly related to #1504 (fixed in 6.3.1 for nullable parameters). 6.3.1 does not fix this case for us.

Environment

  • NUnit3TestAdapter 6.3.1 (also seen with 6.3.0)
  • NUnit 5.0.0 (also seen with 4.6.1)
  • Microsoft.NET.Test.Sdk 18.10.1 (also seen without it)
  • EnableNUnitRunner = true, OutputType = Exe, net10.0
  • global.json: "test": { "runner": "Microsoft.Testing.Platform" }
  • Visual Studio: 2026 Insiders [12308.306], Real Time Discovery: ON

Repro

NUnitEnumTestCaseRepro.zip

  1. Open NUnitEnumTestCaseRepro.csproj in Visual Studio (File > Open > Project/Solution).
  2. Build. Test Explorer shows 14 tests.
  3. Run all tests.
  4. Look for tests with an enum parameter that now appear twice: one passed entry and one "not run" entry.

Expected: 14 tests, all passed, one entry per test case.

Image

What the project covers

Test class Parameter Expected to duplicate?
IntParameterTests int control
TopLevelEnumTests enum at namespace level to be determined
NestedEnumTests enum nested in the test class (sync and async) to be determined
ParameterizedFixtureWithNestedEnumTests nested enum + [TestFixture(arg)] + primary constructor to be determined

In our real solution the tests that duplicate all take a nested enum as [TestCase] parameter (inside a
parameterized [TestFixture] with a primary constructor). Tests without parameters, and parameterized
fixtures without [TestCase] parameters, are not duplicated.

Observed in our real solution

The entry created at execution time has a different name than the discovered one:

  • Discovered: ProcessWorkflowAutoStarter(DisableFeature)
  • Executed: ProcessWorkflowAutoStarter(Execution.Tests.ExecutionProcessWithTestOrderServerTest+WorkFlowAutoStarterTestCase)
    (fully qualified type name of the parameter, nested type separated by +)

The discovered entries stay "not run". Deleting .vs\<solution>\v18\TestStore and restarting shows the correct
count until the first build, then the duplicates return.

Microsoft.Testing.Platform itself discovers the correct number of tests: <exe> --list-tests and dotnet test
report each test case once and all pass.

Activity

  1. OsirisTerje commented on Oct 20, 2026

    @OsirisTerje
    Member

    Turn off the Real Time Test Discovery (RTD), those nodes that are not run, are ghost nodes from the RTD. It's Microsoft's attempt of figuring out the test cases before anything is run, it doesn't always match.

    I agree it is a bit strange that NoParameter seems to exist as identical doubles. Also I see that the not-run node has source info added, but the node that run don't , so that is a bit strange. They must somehow be different.

    We have to look into this. Thanks for the repro!

    Image
  2. OsirisTerje commented on Oct 20, 2026

    @OsirisTerje
    Member

    @Evangelink This looks a lot like the same bug as in #1504 . You mentioned something about other possible cases. Can this be in the same league? And can we fix it in the adapter ?

  3. OsirisTerje commented on Oct 20, 2026

    @OsirisTerje
    Member

    The source code link comes from the RTD, MTP suppress it for test results. Further MTP doesn't understand the NUnit format (and I don't think they ever will fully support the NUnit format), since they have bound themselves to the C# FQN, but NUnit expands that by having parameters on fixtures.

    We will see if we can merge the two together, but the test explorer will then not show the nodes the same way.
    I believe if you skip MTP this would work better.

    But @Evangelink will not like me anymore if I don't do anything here, so..... here we go !

  4. added
    MTP
    on Oct 20, 2026
  5. OsirisTerje commented on Oct 20, 2026

    @OsirisTerje
    Member

    @tom-englert

    We can tweak it for MTP to something like this:

    Image

    Further, we can tweak the format a bit, like for these options:

    Format Example leaf
    current ParameterizedFixtureWithNestedEnumTests(A).NoParameter
    arguments only, as prefix (A).NoParameter
    arguments only, as suffix NoParameter [A]

    We are constrained by MTP because it uses the same field, TestMethodIdentifierProperty.TypeName, both to match tests to source code and to build the Test Explorer hierarchy, and MTP has no separate property for display grouping. If the fixture arguments are in that field, real-time discovery cannot match the nodes and shows duplicates; if they are left out, all fixture instances fall under one class node.

    We can only change the leaf node, the name of the test itself, and that is what we have done here.

    The options above could also be added as runsettings options.

    Just to show the first attempt, resulting in all under one node:

    Image

    Is this helping, @tom-englert ?

  6. added this to the 6.4 milestone on Oct 20, 2026
  7. OsirisTerje commented on Oct 21, 2026

    @OsirisTerje
    Member

    @tom-englert You can check this out using the Myget package, version 6.4.0-alpha.0.25, see https://docs.nunit.org/articles/nunit/getting-started/downloading.html#developer-versions for how to set it up.

    Please confirm it works for you.

  8. tom-englert commented on Oct 22, 2026

    @tom-englert
    Author

    @OsirisTerje I can confirm that 6.4.0-alpha.0.25 fixes the issue. Thanks!

  9. Evangelink commented on Oct 26, 2026

    @Evangelink
    Contributor

    Sorry for the delay @OsirisTerje! I was OOF sick all past week and just resuming now. Please let me know if you want me to have a look at something (including expanding something on MTP).

  10. OsirisTerje commented on Oct 26, 2026

    @OsirisTerje
    Member

    Thanks @Evangelink !

    Right now I think I have a sort of control. I'm reverse enginering what you do other places (aka MSTest), and of course MTP itself, so I do manage to get the information I need.

    But I will ping you when something needs to be clarified.

    I have been focusing lately on the FQNIssues, they are overdue, and checking them against both VSTest and MTP. Currently I need more information from the Test Explorer, so creating a tool for extracting that information using Windows Automation. That way I can use Claude to also "see" what Test Explorer do. That will also help when I later now work through all the MTP issues. That is also overdue.

    The FQNIssues parent epic was created way back (2018) by @peterwald , #505 and show all issues we have with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MTPclosed:doneis:bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions