I am running lots of tests which benefit from being run 'Isolated' (because they're testing embedded code which has lots of static state, and spinning-up a new process is the simplest way of avoiding interactions).
Am I right in thinking that if I put [Isolated] on a test fixture class, all the tests within that fixture share the same process? i.e. If I want each test to be isolated, I need to remember to annotate each test individually? I think that's my reading of http://www.ncrunch.net/documentation/reference_runtime-framework_isolated-attribute , anyway.
A couple of things:
* Am I right about the way it works?
* if I have '[Isolated]' on a base class which lots of test fixtures share, do they each run isolated, or do I need to mark each one?
* Could we have a 'IsolatedMembers' sort of attribute which individually isolated each test? (i.e. analogous to the effect of putting [Isolated] on an assembly, which apparently separately isolates each member fixture rather than the whole assembly.)
willdean wrote:
Am I right in thinking that if I put [Isolated] on a test fixture class, all the tests within that fixture share the same process? i.e. If I want each test to be isolated, I need to remember to annotate each test individually? I think that's my reading of http://www.ncrunch.net/documentation/reference_runtime-framework_isolated-attribute , anyway.
Your understanding is correct. When declared at fixture-level, the methods within the fixture can still be run together with the isolation being performed at fixture level. It should be noted that this does not guarantee that all tests within the fixture will be run within a single execution run (the runner can make multiple calls if the tests happen to be long running or marked with ExclusivelyUsesAttribute).
willdean wrote:
* if I have '[Isolated]' on a base class which lots of test fixtures share, do they each run isolated, or do I need to mark each one?
NCrunch considers inheritance when detecting this attribute, so yes, applying the attribute to a base class will make it apply to all descendants at fixture level. Likewise, applying the attribute to a virtual method which is overridden in descending classes will result in the attribute being applied to tests that descend from it (at test level).
willdean wrote:
* Could we have a 'IsolatedMembers' sort of attribute which individually isolated each test? (i.e. analogous to the effect of putting [Isolated] on an assembly, which apparently separately isolates each member fixture rather than the whole assembly.)
At the moment this doesn't exist, but it's a good idea. You're welcome to request it as a feature if you like :)
Thanks - I've put the uservoice request in. I suppose in the spirit of uservoice I should now try and persuade a pile of people on Twitter to vote for my idea :-)
willdean wrote:Thanks - I've put the uservoice request in. I suppose in the spirit of uservoice I should now try and persuade a pile of people on Twitter to vote for my idea :-)
Absolutely :) There's a growing list of ideas to compete with!