Skip to content

Pre-Filtering in NUnitLite has problems #3454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
oznetmaster opened this issue Dec 31, 2019 · 8 comments
Closed

Pre-Filtering in NUnitLite has problems #3454

oznetmaster opened this issue Dec 31, 2019 · 8 comments
Milestone

Comments

@oznetmaster
Copy link
Contributor

There appears to be an issue with the pre-filtering in NunitLite.

If there is a a namespace a.b which contains a SetupFixture, and a namespace a.b.c which has a test method a.b.c.TestMethod, and only the test a.b.c.TestMethod is specified, the setup fixture's OneTimeSetup and OneTimeTearDown methods are never run.

Apparently, the pre-filtering excludes the a.b namespace from consideration.

It would seem that pre-filtering should examine all parent namespaces for a SetupFixture, even if tests in those namespaces are excluded by the pre-filtering.

Maybe there needs to be a simple way to turn pre-filtering off entirely?

@CharliePoole
Copy link
Member

This sounds familiar. Has it come up before?

@CharliePoole
Copy link
Member

Ah! It's #3356, but that was fixed and closed by changing the VS adapter - eliminating pre-filtering as a default. So the issue was never dealt with in nunitlite.

As a workaround, pass in a pre-filter that always succeeds, rather than taking the default.

@oznetmaster
Copy link
Contributor Author

However #3356 really did not fix the problem, only eliminated the trigger.

Could this be solved by simply searching the entire test assembly for classes with the SetupFixture attribute, and automatically adding them to the pre-filter?

@oznetmaster
Copy link
Contributor Author

oznetmaster commented Jan 1, 2020

I fixed this problem in my CF version as above.

In DefaultTestAssemblyBuilder.

		private void AddSetupFixturesToPreFilter (Assembly assembly)
			{
			foreach (Type type in assembly.GetTypes ())
				{
				if (type.IsClass && type.HasAttribute<SetUpFixtureAttribute> (false))
					_filter.Add (type.FullName);
				}
			}

and

				AddSetupFixturesToPreFilter (assembly);

just before

				var fixtures = GetFixtures (assembly);

I am not setup to modify the release code, so someone else will have to do this if it is desired.

This should fix the adapter problem as well.

@CharliePoole
Copy link
Member

I think that will run all setup fixtures in the discovery phase, not just those that relate to the selected tests.

@mikkelbu
Copy link
Member

mikkelbu commented Jan 1, 2020

This issue is also related to #3399

@NN---
Copy link

NN--- commented Sep 20, 2020

Still an issue with latest NUnitLite.

@rprouse
Copy link
Member

rprouse commented Dec 14, 2020

Resolved by #3679

@rprouse rprouse closed this as completed Dec 14, 2020
@rprouse rprouse added this to the 3.13 milestone Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants