Native support for xUnit Collection attributes
Currently xUnit Collection attributes are not prohibiting nCrunch from running tests inside one collection in parallel. So developers require to decorate old tests with nCrunch-related attributes for those test not to be executed in parallel.
-
Hi John,
If you mark the tests involved with NCrunch.Framework.IsolatedAttribute, does this suppress the issue? Is there any chance you can share a code sample that can reproduce the problem? I'm always happy to help in the support forum with issues like this one. There should be a way we can resolve this problem for you.
-
John Bubriski commented
I think this is the problem I'm running into... I have a Collection that's sharing a resource and throws if something attempts to reinitialize it. As far as I can tell, I have disabled "Allow parallel test execution", but I'm still running into the error. The XUnit tests have been running fine with the normal runner in Visual Studio. This is a show-stopper for us right now in adopting this product.
-
There is a key difference between parallelisation in xUnit vs NCrunch: xUnit runs tests in parallel within the same process (i.e. different thread), where NCrunch runs tests in parallel in different processes (i.e. different process).
This means that a test that cannot be parallelised in xUnit may still be parallelisable using NCrunch. For example, if a test is making use of code that isn't thread-safe and is making use of static state, it can't be parallelised using xUnit, but can still be parallelised using NCrunch. If a test is making use of a shared resource on the file system, it cannot be parallelised by either.
This makes it unwise for NCrunch to simply assume that a test fixture marked with an xUnit collection cannot be parallelised. Really, these are two completely different mechanisms and the only way for NCrunch to know whether the test should have parallelisation restrictions in place for cross-process parallelisation is through specialised attributes targeted towards NCrunch (i.e. ExclusivelyUsesAttribute).