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!
Feature Suggestions
Use Attribute to control which Tests can be run in parallel
Started by ChrisPerluss on 6,729 views
Remco NCrunch Developer
#1458
14 Mar 2012 20:29 UTC
Hi Chris,
Thanks for posting!
Exactly such a thing exists - it's called the 'ExclusivelyUses' attribute :)
https://www.ncrunch.net/documentation/reference_runtime-framework_exclusively-uses-attribute
Cheers,
Remco
Thanks for posting!
Exactly such a thing exists - it's called the 'ExclusivelyUses' attribute :)
https://www.ncrunch.net/documentation/reference_runtime-framework_exclusively-uses-attribute
Cheers,
Remco
Edited 14 Mar 2012 20:29 UTC
Thanks, you rock!
Post a reply
Log in to reply.