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

Notification

Icon
Error

Difference between ExclusivelyUses and Isolated.
GreenMoose
#1 Posted : Monday, February 18, 2013 12:52:34 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 503

Thanks: 142 times
Was thanked: 66 time(s) in 64 post(s)
Hi.

I have test structures something like below:

Code:
public abstract TestBase() {}
public abstract IntegrationTest : TestBase {}
[TestFixture]
public MyClassTest : IntegrationTest


I want my integration tests (hitting datbase) to not be run in parallel, but since it takes about ~10sec to wire up the test session (using NHibernate), I want as much as possbile tests for an integration test to be run within same process (to keep it fast since first test always takes ~10sec to initialize the static session factory).

So,
1) do [ExlusiveUses("Database")] and [Isolated] work in similar way for this, or am I better of with one or the other?
2) Does it matter that the abstract base class does not have [TestFixture] attribute?

Thanks.
Remco
#2 Posted : Monday, February 18, 2013 8:32:35 PM(UTC)
Rank: NCrunch Developer

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

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

It's correct to use the 'ExclusivelyUsesAttribute' for this task. I recommend against using 'IsolatedAttribute', as this will cause each test run to be in a new process (which is counter to the goals you describe above).

Provided the integration tests all have the same exclusively used resource, they should run safely in sequence and will most likely use the same task runner process, although this isn't a rule, and there isn't a way to force to keep them in the same process.

The TestFixture attribute standing alone no longer makes any difference from NUnit 2.5 onwards, so there's no need to specify it. If you have a test class that contains tests but you do not want the test runner to execute them, marking the class as abstract will prevent the running from doing so. You'll notice that tests declared in an abstract class will still exist as part of any non abstract fixture that inherits from it, so this is a great way to re-use tests for difference scenarios.

Cheers,

Remco
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.030 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download