+ Start a Discussion
Brad BothBrad Both 

Apex Test Errors

Hey all, so here's my issue. When I first did some updates through deploying the changes everything went well. I tried to create a class and deploy it and it failed (See my last question). Now we are trying to update another class to have one extra field being collected, when deployed we are getting the exact same errors. I also had to refresh my sandbox before I did this, I have no idea if that makes a difference. Someone did respond with what what each error. In all honesty I'm just very confused as to why with minimal changes to the controller is it throwing errors when it was fine last week. I'm assuming the issue isn't from the controller at all but something else entirely. Here are the errors, please let me know if you need anything else to help. Thanks


Here are the 4 errors I'm getting:
CalculateBusinessHoursAgesTest || testBusinessHoursBucketer || System.Exception: Assertion Failed 
Stack Trace: Class.CalculateBusinessHoursAgesTest.testBusinessHoursBucketer: line 29, column 1

Catalog_Controller_Test || runTest || System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Carrier can not be North America for overseas shipments.: [Preferred_Carrier__c] 
Stack Trace: Class.Catalog_Controller_Test.runTest: line 32, column 1

Milestone1_Test_Field_Values || testFieldValues || System.AssertException: Assertion Failed: Expected: -1789.690000000000000000000000000000000001, Actual: -1789.69 
Stack Trace: Class.Milestone1_Test_Field_Values.testFieldValues: line 245, column 1

OppPusherTests || myOppUnitTest || System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Opportunity_SetPricebook: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.Opportunity_SetPricebook: line 16, column 1: [] 
Stack Trace: Class.OppPusherTests.createOppty: line 73, column 1 Class.OppPusherTests.myOppUnitTest: line 30, column 1


Unfortunately you will have to fix all these errors before you can deploy any apex classes or triggers into Production. Salesforce enforces this rule to make sure the current processes won't break. 

In your developer sandbox, run all tests and see if these test classes also break. If they are, you can fix them in your developer sandbox and deploy them to Production with your new changes.