• min liu
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
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:

@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