You need to sign in to do that
Don't have an account?
Lakshmi S
Test class for Rollup summary Trigger (100% code coverage)
Hi Team,
1. Write a test class for Rollup Summary Trigger , must cover 100% code coverage?
2. Without writing Test class shall we deploy the Trigger from Sandbox to Produntion. Explain?
Trigger Code :
Thanks
Lakshmi.
1. Write a test class for Rollup Summary Trigger , must cover 100% code coverage?
2. Without writing Test class shall we deploy the Trigger from Sandbox to Produntion. Explain?
Trigger Code :
trigger RolllupSummaryOppAmt on Opportunity (After insert, After update,After delete, After undelete) { if(checkRecursive.runOnce()){ Set<Id> accid = new Set<Id>(); Decimal avgamt; Decimal sumamt; Integer noopp; if(Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete){ for(Opportunity opp : Trigger.New){ if(opp.AccountId != null){ accid.add(opp.AccountId); } } } if(Trigger.isDelete || Trigger.isUpdate){ for(Opportunity op : Trigger.Old){ if(op.AccountId != null){ accid.add(op.AccountId); } } } List<Account> aclist = [select id,OppAvgAmount__c,SumOfOppAmt__c,NoOfOpp__c,(select id,amount from opportunities) from account where id In :accid]; List<Account> upacc = new List<Account>(); if(aclist.size()>0){ for(Account ac : aclist){ List<AggregateResult> aglist = [select count(id)t,avg(amount)agg,min(amount)sumamt from opportunity where accountid = :ac.id]; for(AggregateResult ag : aglist){ avgamt = (Decimal)ag.get('agg'); sumamt = (Decimal)ag.get('sumamt'); noopp = (Integer)ag.get('t'); system.debug('---average---:'+avgamt); } ac.OppAvgAmount__c = avgamt; ac.SumOfOppAmt__c = sumamt; ac.NoOfOpp__c = noopp; upacc.add(ac); } update upacc; } } }
Thanks
Lakshmi.
Any one help me how to cover the 100% code coverage for above trigger.
Regards
Lakshmi