[v5.13]
Background:
I'm working in a legacy xUnit project and I want to introduce the use of NUnit instead (for multiple reasons). Some people are using Macs and cannot be persuaded to take advantage of NCrunch.
Problem:
I noticed that when using [Parallelizable] with NUnit 4.3.2 (to make it "as fast" as xUnit for running tests), NCrunch warns about this usage and that it may cause instability.
Questions:
1) Does this mean that NCrunch can more reliably and automatically disable parallel test runs with xUnit, but not with NUnit?
2) Is there a recommended approach to avoid removing this attribute, while simply skipping it when NCrunch is the active runner? Or is a conditional mutex setup/teardown (used only if NCrunch is active) the best way to ignore the NCrunch warning, or would this approach still cause NCrunch to misbehave?
Thanks!
Remco NCrunch Developer
#18241
17 Jul 2025 23:05 UTC
Hi, thanks for posting.
Yes. Xunit has a configuration option that, when passed in, can shut off all parallel behaviour. Our control over NUnit in this situation is somewhat more limited.
A Mutex isn't sufficient, as NCrunch requires test execution to be entirely synchronous otherwise results tracking goes completely haywire.
The only way to solve this is to remove ParallelizableAttribute. If your team is using other tools, it might be best to do this with a compiler condition, i.e.:
#if !NCRUNCH
[Parallelizable]
#endif
Questions:
1) Does this mean that NCrunch can more reliably and automatically disable parallel test runs with xUnit, but not with NUnit?
Yes. Xunit has a configuration option that, when passed in, can shut off all parallel behaviour. Our control over NUnit in this situation is somewhat more limited.
2) Is there a recommended approach to avoid removing this attribute, while simply skipping it when NCrunch is the active runner? Or is a conditional mutex setup/teardown (used only if NCrunch is active) the best way to ignore the NCrunch warning, or would this approach still cause NCrunch to misbehave?
A Mutex isn't sufficient, as NCrunch requires test execution to be entirely synchronous otherwise results tracking goes completely haywire.
The only way to solve this is to remove ParallelizableAttribute. If your team is using other tools, it might be best to do this with a compiler condition, i.e.:
#if !NCRUNCH
[Parallelizable]
#endif
Edited 17 Jul 2025 23:06 UTC
Post a reply
Log in to reply.