Skip to content

Generic Test Fixtures not run from VS Test Explorer #1280

@manfred-brands

Description

@manfred-brands

This is using any version of the adapter up to 5.1.0-alpha.3 and either nunit 3.14.0 or 4.3.2.

Given the following test:

[TestFixture(TypeArgs = [typeof(object)])]
[TestFixture(TypeArgs = [typeof(string)])]
internal sealed class GenericFixtureWithProperArgsProvided<T>
{
    [Test]
    public void SomeTest()
    {
        Assert.That(typeof(T).IsClass, Is.True);
    }
}

Running dotnet test gives:

NUnit Adapter 5.0.0.0: Test execution started
Running all tests in D:\Development\3rd\nunit\nunit.issues\IssueXXXX\bin\Debug\net9.0\IssueXXXX.dll
   NUnit3TestExecutor discovered 2 of 2 NUnit test cases using Current Discovery mode, Non-Explicit run
NUnit Adapter 5.0.0.0: Test execution complete
  IssueXXXX test succeeded (0.9s)

Test summary: total: 2, failed: 0, succeeded: 2, skipped: 0, duration: 0.9s
Build succeeded in 1.3s

Right clicking Run Tests in VS Solution Explorer or Running test from Test Explorer gives;

Image

I have traced it down to the NUnit.Prefilter setting:

  <NUnit>
      <PreFilter>true</PreFilter>
  </NUnit>

We have enabled this on all our projects as a suggested performance improvement:
See nunit.docs

Changing prefilter to false causes it to work.

Is this something that can be fixed or do we have to disable the Prefilter and how does that affect performance on our bigger projects.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions