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

Notification

Icon
Error

Use Attribute to control which Tests can be run in parallel
ChrisPerluss
#1 Posted : Wednesday, March 14, 2012 7:41:52 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/14/2012(UTC)
Posts: 2
Location: California, USA

Was thanked: 1 time(s) in 1 post(s)
We'd like to run our unit tests in parallel but we can't because some tests write to
the same database tables and would clobber each other. Each test case cleans up
after itself so that they do not cause each other to fail when run separately but if
run at the same time it would be a problem.

I'd like to be able to specify an attribute on the test methods which accepts a string.
This string could be used to create a mutex to make sure that no two tests with the
same mutex run at the same time. Tests with different mutexes or without this
attribute could safely be run in parallel.

Given the set of test cases below, I don't want to run the two tests that touch the
PizzaRepository at the same time, nor do I want to run the two tests that touch the
CustomerRepository at the same time.

But it would certainly speed up our unit test process if i could run one PizzaRepository
test, one CustomerRepository test, and both Validation tests concurrently.

Examples:

[TestMethod, TestMutex("PizzaRepository")]
public void TestSavePizzaOrder() {}

[TestMethod, TestMutex("PizzaRepository")]
public void TestUpdatePizzaOrder() {}

[TestMethod, TestMutex("CustomerRepository")]
public void TestSaveCustomer() {}

[TestMethod, TestMutex("CustomerRepository")]
public void TestUpdateCustomer() {}

[TestMethod]
public void TestPizzaOrderValidation() {}

[TestMethod]
public void TestCustomerValidation() {}

Thanks!
Remco
#2 Posted : Wednesday, March 14, 2012 8:29:03 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,140

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Chris,

Thanks for posting!

Exactly such a thing exists - it's called the 'ExclusivelyUses' attribute :)

https://www.ncrunch.net/document...clusively-uses-attribute


Cheers,

Remco
ChrisPerluss
#3 Posted : Wednesday, March 14, 2012 10:07:33 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/14/2012(UTC)
Posts: 2
Location: California, USA

Was thanked: 1 time(s) in 1 post(s)
Thanks, you rock!
1 user thanked ChrisPerluss for this useful post.
Remco on 3/14/2012(UTC)
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.035 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download