You need to sign in to do that
Don't have an account?
ministe_2003
UNABLE_TO_LOCK_ROW in test code since summer 14
Hi all,
Since updating to summer 14 a lot of my tests are failing with the UNABLE_TO_LOCK_ROW error. It's all coming from the same line of code, which is some global code to generate records for testing many different things, such as sample accounts, opportunities etc. This is the section that's failing:
Thanks
Since updating to summer 14 a lot of my tests are failing with the UNABLE_TO_LOCK_ROW error. It's all coming from the same line of code, which is some global code to generate records for testing many different things, such as sample accounts, opportunities etc. This is the section that's failing:
@IsTest(SeeAllData=true) public static void createTestPricebookEntry(){ if(pbeCreated == null){ pbeCreated = false; } if(!pbeCreated){ pbeCreated = true; //stdPbId = Test.getStandardPricebookId(); activate once we update to summer 14 stdPbId = [SELECT Id FROM Pricebook2 WHERE isStandard = true].Id; //deactivate once we update to summer 14 Product2 p2 = new Product2(Name = 'Engineered - Spur', ProductCode = 'EO', isActive = true); insert p2; newProdId = p2.Id; PricebookEntry stdPbe = new PricebookEntry(Product2Id = newProdId, Pricebook2Id = stdPbId, unitprice = 50, useStandardPrice = false, isActive = true, CurrencyISOCode = 'GBP'); insert stdPbe; <-- THIS IS THE FAILING LINE pbeId = stdPbe.Id; } }This method can be called from many different places but is mostly called from another similar test class which creates a test opportunity with product lines. It's causing 20 of my classes to fail which worked perfectly until the update to Summer 14. Does anyone know why this is suddenly failing and what I can do to prevent it? The class is a public but all my variables and methods are static, which I thought should prevent this problem.
Thanks
All Answers
http://docs.releasenotes.salesforce.com/en-gb/summer14/release-notes/rn_apex_price_books_in_tests.htm
http://peterknolle.com/salesforce-pricing-enhancements/