You need to sign in to do that
Don't have an account?
iSqFt_AD
Quick Help on Failed Deployment of Updated Test Class from SB to Prod
This class already exists and is functioning in our Production instance. I made one change to it and am attempting to deploy it into Production and I get an error.
Test Class:
/** * This class contains unit tests for validating the behavior of Apex classes * and triggers. * * See the Apex Language Reference for more information about Testing and Code Coverage. */ @isTest private class testTriggerSet { static testMethod void myUnitTest() { // TO DO: implement unit test //test of leadDuplicatePreventer Lead l = new Lead(); l.LastName = 'tester smith'; l.Company = 'tester company'; l.Email = 'tester@tester.com'; l.Phone = '(513) 888-8888'; l.Status = 'Open'; l.LeadSource = 'Kiosk'; insert l; //test of Task t = new task(); t.Subject = 'test task'; t.ActivityDate = Date.today(); t.Type = 'Phone Conversation'; t.Focus__c = 'Sales Activity'; t.WhatId = '001P000000Wfluj'; insert t; Account a = new account(); a.Name = 'tester account'; a.Phone = '(513) 333-3321'; insert a; Opportunity o = new Opportunity(); o.Name = 'tester opp'; o.StageName = 'Proposal Made'; o.CloseDate = Date.today(); o.Amount = 444.23; o.Contract_Length_in_Months__c = 12; insert o; o.StageName = 'Proposal Made'; update o; Contact c = new Contact(); c.LastName = 'tester'; c.Email = 'joe@sss.com'; c.Phone = '(513) 332-3321'; insert c; } }
Update Made:
o.Contract_Length_in_Months__c = 12;
Error when attempting to Validate:
testTriggerSet.myUnitTest() | Class | 31 | 1 | Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []", Failure Stack Trace: "Class.testTriggerSet.myUnitTest: line 31, column 1" |
Try this.
All Answers
I think, this might be the problem. You are using hardcoded Id. Can you please check whether you have this id in production?
Try this.
Good eye, but what is really odd is that the class in Production does not have that in it, and I did not just add it. What is really odd about that is that I am the only Admin with access to the Sandbox.
No idea how this happened but I believe you are correct.