RunTestSynchronous through REST Tooling API fires assignment rules when creating a case in synchronous apex test
Last updated 2017-10-14 ·Reference W-3808936 ·Reported By 2 users
Summary
RunTestSynchronous through REST Tooling API fires assignment rules when creating a case in synchronous apex test
Developer Console uses Rest Tooling API, thus, the issue is also replicable by running a test class in synchronous mode from developer console to insert records.
Repro
1) Create an assignment rule for case
2) Create a test class and insert a case matching the assignment rule criteria
@isTest
private class assignmentRuleTEST{
static testMethod void checkOwnerCreated() {
Case c = new Case(Subject='MyTestCase');
insert c;
ID createdByUserID = UserInfo.getUserId();
Case insertedCase = [Select ID, OwnerID From Case Where ID=:c.Id];
System.debug(createdByUserID+'--'+insertedCase.OwnerID);
System.assertEquals(createdByUserID , insertedCase.OwnerID);
}
}
3) Go to Developer Console.
4) Under 'Test', make sure "Always run Asynchronously" is not checked.
5) Select 'New Run' under 'Test' tab.
6) Select class 'assignmentRuleTEST' > Method 'checkOwnerCreated'
7) Click 'Run'
Assertion Failed: Expected:
005xxxxxxxxxxxxxx, Actual: 00Gxxxxxxxxxxxxxx
Notice: 00Gxxxxxxxxxxxxxx ,- Has been assigned to queue as per Assignment Rule
Workaround
None
Reported By (2)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.