You need to sign in to do that
Don't have an account?
Peter Bölke
How to test a Roll-Up Trigger
Hello,
i have a problem testing my Roll-Up Trigger. Here it is:
It doesnt update the value SoldUnits__c at Account 'A1' which is the grandparent Account.
Any Idea?
Thanks
Peter
i have a problem testing my Roll-Up Trigger. Here it is:
@isTest(SeeAllData=true) public class TrgTractorFleetSizeRollupTest { static testmethod void validateUploadNewAccount(){ Account a1 = new Account(Name = 'A1'); insert a1; Account a1a1 = new Account(Name = 'A1A1', ParentId = a1.id); insert a1a1; Account a1a1a1 = new Account(Name = 'A1A1A1', ParentId = a1a1.id, SoldUnits__c = 125); insert a1a1a1; Account a1a1a2 = new Account(Name = 'A1A1A2', ParentId = a1a1.id, SoldUnits__c = 125); insert a1a1a2; System.debug([SELECT Id, SoldUnits__c from Account Where Name = 'A1A1'][0]); Account a1a2 = new Account(Name = 'A1A2', ParentId = a1.id); insert a1a2; Account a1a2a1 = new Account(Name = 'A1A2A1', ParentId = a1a2.id, SoldUnits__c = 100); insert a1a2a1; Account a1a2a2 = new Account(Name = 'A1A2A2', ParentId = a1a2.id, SoldUnits__c = 90); insert a1a2a2; System.debug([SELECT Id, SoldUnits__c from Account Where Name = 'A1A2'][0]); System.debug(a1a2.SoldUnits__c); System.assertEquals([SELECT Id, SoldUnits__c from Account Where Name = 'ss'][0].SoldUnits__c, 450); } }
It doesnt update the value SoldUnits__c at Account 'A1' which is the grandparent Account.
Any Idea?
Thanks
Peter
All Answers
here is my Trigger...
Thanks in advance for any advise
the account you mentioned is one which exist. I tried tthe test there but without success.
I changed the code in this way
But his give me another error 'insert la;' : "System.DmlException: Insert failed. First exception on row 4 with id 0013E00000XRoKhQAL; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]"
But endend up with: "System.AssertException: Assertion Failed: Expected: null, Actual: 450"
thats ok. Only the "lowest" Elements in this Hierarchy should have manually entered values.