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!