function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Brian YarsawichBrian Yarsawich 

Case Assignment Rules are not firing on Test Suite run.

I am running into a very strange issue with my unit tests.  When I run each test or test class individually they all pass fine.  The problem occurs when I try to run multiple tests at once or a test suite I put together.  I've been using case assignment rules to put new cases into queues and they work fine.  The problem I've found from going through the debug logs is that when more than one test is run at once, the case assignment rules never get called.  Going through the logs I don't even see them mentioned though other custom workflows do get triggered.

Does salesforce skip case assignment rules when running large tests?  If so will this cause a failure for deployment to production and if it will is there a way to make the case assignment rules fire?
Kai MederKai Meder
Same here, case assignment rules are not being applied when running a test suite.
When running a testClass individually though, case assignment rules are applied just fine.

Andree WilleAndree Wille
Same Issue here. This is very annoying! Anyone who knows a workaround or knows how to fix this issue?
Brian YarsawichBrian Yarsawich
Probably should have psoted this earlier, but I found a solution.  If you set the DMLOptions to use the case assignment rules before an insert or update then the case assignment rules will fire during tests.
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
insert theCase;
Andree WilleAndree Wille
Thank you, that helps. Even though it feels weird to set dml options in my code that already uses assignment rulesi just to get the tests working.