Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am getting the this error when I “Run All Tests” however the error disappears when I run test for individual classes. With All Tests most of the classes give same error.

*Error Details *

Error Message System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, trgOrphanId: execution of AfterInsert

caused by: System.QueryException: Record Currently Unavailable: The record you are attempting to edit, or one of its related records, is currently being modified by another user. Please try again.

Trigger.trgOrphanId: line 23, column 1: [] Stack Trace Class.testBatchDonorAllocation.myUnitTest: line 39, column 1

help will be much appreciated.

Thanks,

Regards,

share|improve this question
    
can you post your code to see the error line? –  Baskaran S Mar 31 at 9:49
    
It may be due to one of the test class deleting or invoking a trigger with delete event.You may enable Parallel Apex Testing from options in 'Apex Test Execution' and then try to run all again. –  userRg Mar 31 at 9:55
    
thanks @baskaran, Disable Parallel Apex Testing worked. thanks –  Mahmood Mar 31 at 10:51

1 Answer 1

up vote 3 down vote accepted

In Setup's "Apex Test Execution" page there is an "Options" button that includes a "Disable Apex Parallel Testing" checkbox. Checking that will probably avoid the problem.

share|improve this answer
    
thanks Keith C, by disabling parallel testing, all the tests are now passing. Amazing! thanks for help, you have saved my many hours and may be days. you are great. –  Mahmood Mar 31 at 10:44
    
@Mahmood In my experience where you have multiple tests touching the same SObject (which is pretty common in Salesforce code bases) the parallel testing runs you into this problem. –  Keith C Mar 31 at 10:48
    
Keith C, will try to deploy change set to live. I hope it wouldn't throw error this time. thanks again –  Mahmood Mar 31 at 10:54
    
@Mahmood I think parallel testing is turned off for deployments to production. –  Keith C Mar 31 at 10:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.