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



Ensure test resource is initialized with parallel testing?
#1 Posted : Tuesday, June 26, 2018 12:14:18 PM(UTC)
Rank: Advanced Member

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

Thanks: 85 times
Was thanked: 40 time(s) in 39 post(s)

I have a test project where a static initialization requires a startup-initialization of a resource which then tests are using.

Is there a way to tell NCrunch to run this initialization "isolated" in the context of current test node ("local" or grid nodes)?

E.g. I have test1+2 requiring a test db to be set up, but these tests are allowed to be run in parallel and the test db is setup as part of a static construction, but this causes issues when both tests are starting simultaneously since they both run the initialization routine on (local).

#2 Posted : Tuesday, June 26, 2018 12:49:02 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,277

Thanks: 695 times
Was thanked: 856 time(s) in 814 post(s)
ExclusivelyUsesAttribute can be used for this. Its scope is the machine (not the whole grid), so using this attribute would solve your problem. Though of course this would then prevent the tests from being run in parallel at all.

I would actually solve this in your test code by using a system-wide Mutex for the initialization code. Here's an example of how to do this.
1 user thanked Remco for this useful post.
GreenMoose on 6/26/2018(UTC)
Users browsing this topic
Guest (3)
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.018 seconds.