I think there is another problem here. I'm helping a colleague investigate this.
Short explanation: I'm doing some integration tests, and part of the fixture is to host a socket server.
Now I applied the little work around with static to ensure Fixture initialization is only ran once, but the problem is with nCrunch parallelisation.
It appears as though nCrunch parallalizes Tests even inside a single TestClass (xUnit btw specifies a Testclass as the smallest unit of parallelisation).
In any case, as far as I can see, this is not done via threads but cross nCrunch worker processes, so the static trick doesn't work.
Each of these will initialize the fixture, but since Ports are a system wide resource, randomly, if the tests inside a fixture happen to be ran in parallel by nCrunch, the fixture setup will fail (it tries to double bind to a port). I could assign just a random free port. But, I do some Sql setup too, which would lead to unpredictable outcome for sure.
The only thing I can see in nCrunch docu is to apply the Isolated or Serial attribute to the TestClass. I guess that would solve it, although my tests could run in parallel.
Also, I would prefer not to take dependencies on a runtime ncrunch library.
Is this the recommended way to do this?
Is it true/intended behaviour that nCrunch runs indivdual tests inside a single testclass in parallel?
Brad Wilson says:
Quote:we have solidified on the design of the test collection being the boundary for parallelization. Allowing test methods in the same class to be in different test collections is a major breaking change with regard to fixtures.
As far as I understand, in the absence of a CollectionFixture the TestClass represents the TestCollection.
https://github.com/xunit...7#issuecomment-53200594
Is it intended behaviour to go against this? (I can see how for "normal" unit tests multi process parallalisation like nCrunch seems to do should work just fine)
My tests could run in parallel, IF the fixture was only done once, that is they could be run in parallel in the same nCrunchWorker process, but not cross workerProcess.