Open jnm2 opened 6 years ago
I'd like to suggest some commentary about enabling parallel-by-default at the test assembly level using [assembly: Parallelizable(...)]
(in particular whether it should be [assembly: Parallelizable(ParallelScope.All)] or [assembly: Parallelizable(ParallelScope.Children)] or not).
I guess this is clear from other statements that say only to use Self
, Fixtures
or Children
(and not All
) but it takes a bit of figuring out to reach that conclusion.
This will be a tricky thing to write because there are wide ranges of opinion as to the best way to use ParallelizableAttribute
at assembly-level, or even whether to use it at all. I feel strongly that writeups about how NUnit works should be separate from subjective advice about how to best use it.
This will be a tricky thing to write because there are wide ranges of opinion as to the best way to use ParallelizableAttribute at assembly-level, or even whether to use it at all.
I defer to the experts on this. Would it be accurate (and sufficiently un-opinionated) to describe the behaviour without making any recommendation with something like the following?
"Applying [assembly: Parallelizable(ParallelScope.Children)]
will result in all fixtures, child tests, and test cases/[Values]
running in parallel, unless they in turn have Parallelizable
attributes applied to override this behaviour."?
Some folks will be interested in doing that, so that would be a valuable description. I wouldn't necessarily call out [Values]
in particular.
We've seen a few examples of folks asking why parallelism isn't working for them and it turns out that they're not realizing that they're sharing mutable state between threads. Sometimes it's something global and static, sometimes it's mutable fixture instance state because they expect a new fixture instance per test case. It would be good to provide examples of how to keep state separated, and what not to do (SetUp/TearDown), and why.
Here's an overly-complex example for a real-world project where I refactored from SetUp/TearDown toa parallel-safe solution: https://github.com/nunit/nunit/issues/2105#issuecomment-325347460