Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Precise Meaning Of Isolated on a Test class
willdean
#1 Posted : Monday, February 23, 2015 7:32:34 PM(UTC)
Rank: Member

Groups: Registered
Joined: 1/31/2012(UTC)
Posts: 25
Location: England

Thanks: 7 times
Was thanked: 2 time(s) in 2 post(s)

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/d...work_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.)

I understand the caveats about performance.

Thanks,

Will




Remco
#2 Posted : Monday, February 23, 2015 10:03:11 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Will,

Thanks for posting.

willdean;7005 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/d...work_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;7005 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;7005 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 :)
willdean
#3 Posted : Tuesday, February 24, 2015 9:22:05 PM(UTC)
Rank: Member

Groups: Registered
Joined: 1/31/2012(UTC)
Posts: 25
Location: England

Thanks: 7 times
Was thanked: 2 time(s) in 2 post(s)
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 :-)

Remco
#4 Posted : Tuesday, February 24, 2015 9:35:01 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
willdean;7013 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!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.037 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download