function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sflearningsflearning 

trigger test class help

trigger abcAccount on Opportunity (before update) {
    list<id> oppIds = new list<id>();
    Set<Id> AccountIds = new Set<Id>();

    //if(trigger.isInsert || trigger.isUpdate){
        for(opportunity opp : trigger.new){
        accountIds.add(opp.AccountId);
        }
            Map<Id, Account> accountMap = new Map<Id, Account>([SELECT Name FROM Account WHERE Id IN :accountIds]);
String sName;
for (Opportunity op : Trigger.new) {

  // add the account name
  sName = accountMap.get(op.AccountId).Name;
  System.debug('Account name'+sName);
  
            if(sName=='Axis'){
            // system.debug('opp'+opp);
                op.amount = op.amount*10/100;
                //oppIds.add(op.id);
            }
        
    }

}

 
Devanshu soodDevanshu sood
@istest
public class abcaccount {
    
    @istest
    static void tfunc(){
        
        Account acc=new Account(name='Axis');
        insert acc;
        opportunity opp=new opportunity(name='test',stagename='Prospecting',CloseDate=system.today(),accountid=acc.id,amount=1000);
        insert opp;
        opp.name='abc';
        update opp;
    }

}


100 % code coverage