New DiscoveryMode doesn't play nicely with `TestFixtureSource` - Missing GenericFixture
See original GitHub issueVS 2022 / dotnet sdk 6.0.100 .Net Core 3.1 & 5.0 NUnit 3.13.2 Nunit3TestAdapter 4.1.0
After upgrading Nunit3TestAdapter from 3.17.0 to 4.1.0, a number of my tests disappeared from the Visual Studio test runner. If I run through dotnet test I get a Not a TestFixture, SetUpFixture, ParameterizedFixture or TestSuite, but GenericFixture exception logged as a warning (see full stack trace below).
I’ve narrowed this down to being caused by TestFixtureSource - the error can be reproduced with the code sample below.
This seems similar to #869 but I’m still encountering the same exception after upgrading to 4.1. The workaround of changing DiscoveryMode to Legacy in a run settings file does successfully work around this problem.
Repro code:
[TestFixtureSource(typeof(FixtureSources), nameof(FixtureSources.Types))]
public class SomeTest<T>
{
[Test]
public void Foo()
{
Assert.Pass();
}
}
public static class FixtureSources
{
public static Type[] Types =
{
typeof(object)
};
}
Exception:
Exception NUnit.VisualStudio.TestAdapter.NUnitEngine.DiscoveryException, Exception thrown executing tests in C:\git\AsosCore\ApiAuthentication\src\Authentication.Web.Host.Tests\bin\Debug\netcoreapp3.1\Authentication.Web.Host.Tests.dll
Not a TestFixture, SetUpFixture, ParameterizedFixture or TestSuite, but GenericFixture
at NUnit.VisualStudio.TestAdapter.NUnitEngine.DiscoveryConverter.ExtractTestFixtures(NUnitDiscoveryCanHaveTestFixture parent, XElement node) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEngine\DiscoveryConverter.cs:line 258
at NUnit.VisualStudio.TestAdapter.NUnitEngine.DiscoveryConverter.ExtractAllFixtures(NUnitDiscoveryCanHaveTestFixture parent, XElement node) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEngine\DiscoveryConverter.cs:line 219
at NUnit.VisualStudio.TestAdapter.NUnitEngine.DiscoveryConverter.ExtractAllFixtures(NUnitDiscoveryCanHaveTestFixture parent, XElement node) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEngine\DiscoveryConverter.cs:line 198
at NUnit.VisualStudio.TestAdapter.NUnitEngine.DiscoveryConverter.ExtractAllFixtures(NUnitDiscoveryCanHaveTestFixture parent, XElement node) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEngine\DiscoveryConverter.cs:line 198
at NUnit.VisualStudio.TestAdapter.NUnitEngine.DiscoveryConverter.ExtractAllFixtures(NUnitDiscoveryCanHaveTestFixture parent, XElement node) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEngine\DiscoveryConverter.cs:line 198
at NUnit.VisualStudio.TestAdapter.NUnitEngine.DiscoveryConverter.ExtractAllFixtures(NUnitDiscoveryCanHaveTestFixture parent, XElement node) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEngine\DiscoveryConverter.cs:line 198
at NUnit.VisualStudio.TestAdapter.NUnitEngine.DiscoveryConverter.ConvertXml(NUnitResults discovery) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEngine\DiscoveryConverter.cs:line 186
at NUnit.VisualStudio.TestAdapter.NUnitEngine.DiscoveryConverter.Convert(NUnitResults discoveryResults, String assemblyPath) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEngine\DiscoveryConverter.cs:line 140
at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunAssembly(String assemblyPath, IGrouping`2 testCases, TestFilter filter) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestExecutor.cs:line 280
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Discovery exception · Issue #869 · nunit/nunit3-vs-adapter
After investigation, we were able to notice it happened for all tests using generics and a TestFixtureSource to define which types to use....
Read more >Adapter V4 Release Notes
918 New DiscoveryMode doesn't play nicely with TestFixtureSource - Missing GenericFixture; 919 VSTest test case filter does not work with parentheses; 929 Lots ......
Read more >NUnit Generic test fixture not displaying when parameter ...
Try this: [TestFixture(typeof(OrderTaskGenerator), typeof(OrderTaskRequest))] public class TaskGeneratorContractTest<T, TRequest> where T ...
Read more >Chocolatey Software | NUnit 3 Console Runner 3.8.0
This package includes the nunit3-console runner and test engine for version 3 of the NUnit unit-testing framework. Files. Show tools\CHANGES.txt.
Read more >CHANGES.txt
* The new --debug option causes NUnit to break in the debugger immediately before tests are run. This simplifies debugging, especially when the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@OsirisTerje
4.2.0-beta.1works perfectly now. Thank you very much.@afscrome Version 4.2.0-beta.1 released now on nuget.org https://www.nuget.org/packages/NUnit3TestAdapter/4.2.0-beta.1 . It also contains an engine upgrade, which is the reason for the beta. Would appreciate confirmation that it still works for you.