You need to sign in to do that
Don't have an account?
Robert Wynter
Please Help a newbiee create a test class for the following trigger
It's been a long while since I looked into written Apex triggers. I successfully created one a year ago but neglected to creat a test class for it which has now come to bite me in th ARS. If someone can have pitty on me and help me create a test class that would be greatly appreciated
trigger updateAccountStatus on Opportunity (after insert, after update) { list<Id> accIds = new list<Id>(); /* list<Account> accounts = new list<account>(); */ Map<Id, Account> accounts = new Map<Id, account>(); for(opportunity o:trigger.new){ accIds.add(o.accountId); } for(account a:[select Id, Status__c from account where Id IN :accIds]){ for(opportunity opp:trigger.new){ a.Status__c = opp.Status__c; a.Approval_Progress__c = opp.StageName; /*accounts.add(a);*/ accounts.put(a.Id, a); /* if(opp.Status__c=='Active'){ a.Status__c='Active'; accounts.add(a); } */ } } update accounts.values(); /* update accounts;*/ }
Please refer below link for test class creation for trigger.
https://developer.salesforce.com/docs/atlas.en-us.198.0.apexcode.meta/apexcode/apex_qs_test.htm
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.