You need to sign in to do that
Don't have an account?
Shikibu
UNABLE_TO_LOCK_ROW on insert (unit test)
I have a unit test that is throwing UNABLE_TO_LOCK_ROW when it is doing an insert. I don't understand why that should happen. Here's the code (excerpted). The exception is thrown on the insert statement. Because this is a new record, and contained within a test class, how can it throw a UNABLE_TO_LOCK_ROW exception?
@istest
private class MyTest {
...
theQuote = new Quote(Name='Test Quote',
OpportunityId = theOpp.Id,
Term__c=12,
pricebook2id=thePricebook.id);
insert theQuote;
...
}
private class MyTest {
...
theQuote = new Quote(Name='Test Quote',
OpportunityId = theOpp.Id,
Term__c=12,
pricebook2id=thePricebook.id);
insert theQuote;
...
}
FWIW, Here's a link to an article about preventing recursive triggers;
http://appirio.com/category/tech-blog/2009/10/preventing-recursive-future-method-calls-in-salesforce/
There's still some missing context -- if you create a "Test Pricebook" on both sandbox and production, you might be able to get away with using that pricebook in your test for this trigger, but I'd still look at other trigger code.
Things obviously get messy if you have managed packages that are running tests that have triggers that you can't access the code to...