machine / machine.specifications

Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
MIT License
885 stars 178 forks source link

Performance Improvement - Perform test filtering earlier in process #433

Closed neilrees closed 3 years ago

neilrees commented 3 years ago

Move test filtering to AssemblyExplorer where filtering can be carried out before the Context is created which involves creating an instance of the test class. Filtering can be done just by using the Type and is much faster when there are a large number specifications in the test assembly, as it saves instantiating a context for each specification. Sorting by namespace is now carried out after the filter to reduce the size of the sort required.

There is a slight change in behaviour, if an illegal test (e.g. test with two establishes) is excluded from the run, it no longer is called out as an error whereas it did previously. Previously the ContextFactory would have failed to create a context for the illegal test, but now the test is excluded (by tags or class name) before the context is created so the error is not reported. The error is still reported when the bad test is included in the test run.

robertcoltheart commented 3 years ago

Thanks for this, I'll look at it in more detail. I think the change in behavior is not significant, and probably makes more sense given the filtering mechanism anyway.

neilrees commented 3 years ago

Thanks for the review, feedback applied