You need to sign in to do that
Don't have an account?
Test class failures when deploying to production but not in sandbox
I am running into a deployment error with a test class which runs fine in the sandbox. The error I am receiving is Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, QuoteAdoptionAgreementSent: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 0Q0600000005hI8CAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
The line and column from the test class that it is hanging on is the insertion of a task. My test class is as follows and the line getting the error is Line 23. I've checked my system admin profile and it has access to everything. I can't figure this out. Please help.
Thank you,
Amanda
@IsTest
private class TestQuoteAASentUpdateOppCreateCourses
{
private static TestMethod void testTrigger(){
//Step 1 : Data Insertion
Account a=new Account(Name='Test Account');
insert a;
Contact c = new Contact(FirstName='John',LastName='Doe');
insert c;
Opportunity o = new Opportunity(Name='Test Opportunity',closedate=system.today(), stagename='Confirmed Teaching/Class Schedule',Probability=0.95);
insert o;
OpportunityContactRole ocr = new OpportunityContactRole (OpportunityID = o.id, ContactID=c.id, role='Decision Maker') ;
insert ocr;
Quote q= new Quote (Name='Test Quote', ContactID=c.id, OpportunityID=o.id);
insert q;
test.startTest();
//Perform the dml action on which trigger gets fired , like insert, update ,delete , undelete, in your case you have to update account record that you created in above
Task t= new Task (Subject='Email: Sapling Learning Adoption Agreement', WhoID=c.id, WhatID=q.id);
insert t;
// Switch back to runtime context
Test.stopTest();
}
}
Try doing this and looking at the debug log. When looking at your debug log, you can just use Ctrl+F to find the text 'My error = ':
All Answers
Try doing this and looking at the debug log. When looking at your debug log, you can just use Ctrl+F to find the text 'My error = ':
I have no idea why but changing the test start and stop test to the try method fixed the problem.
Thanks!
Amanda
Well, what the try/catch does is catches the error. So you will no longer see the error happen when you have it with the try/catch, but it should still be happening. That's why I wanted you to take a look at the debug log. It should hopefully give you a better response.