• SaraMorganatVenyu
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hello,

 

Over the weekend, our sandbox was upgraded to Winter '12, and many of my Apex tests have failures now.

 

For instance, I have a test that tries to save a Lead without a Last Name (which should lead to an error for a required field missing).

 

My test:

 

static testMethod void testExceptionsConvertCloseNoLead() { 
  myGenHelpers gh = new myGenHelpers();
		
  Lead testLead = gh.getUptimeTestLead();
  insert testLead;
	            	
  testLead.LastName = null;
	            	
   myLeadConvertCloseExtension lcc = new myLeadConvertCloseExtension(new ApexPages.StandardController(testLead));
   lcc.save();
}

 

Last week, and still in production, this test passes successfully.  However, today, it fails.

 

The problem is in this code segment:

 

                try {
	                update this.myLead;
                } catch (DmlException e) {
                    for (Integer i = 0; i < e.getNumDml(); i++) {
				    	System.debug('myClass.save: error: ' + e.getDmlMessage(i));
                        this.myLead.addError(e.getDmlMessage(i)); 
                    }
                    return null;
                }

 

Instead the error being handled gracefully, the test just fails at the upsert.

 

Any thoughts?