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
CK_Young123CK_Young123 

can someone help me to test the Exception?

global class tt {
    WebService static Boolean updateDB(Account[]  fList) {
    Boolean updateFlg = true;
    try{
          Database.SaveResult[] SR  = Database.update(fList,false);
          for(Database.SaveResult lsr:SR){
                if(!lsr.isSuccess()){
                   updateFlg = false;
                     break;   
                 }
           }        
    }catch (Exception e) {
           updateFlg = false;
    }
    return updateFlg;
}
 
     static testMethod void updateDB() {
 
          Account[] fList = [Select o.Name from Account o where o.Name = 'AAA2'];
         for (Account oli1 : fList ){
             oli1.name = 'd';
          }

           System.assertEquals(false, updateDB(fList ));
    }
}
 
 
 
how can i get the Exception not DMLException,how can i test it ?
 
anyway,Excepiton   can't  be appeared in my source?
 
now my coverage can't  be 100%?can someone can give a testmethode?
Thankyou
 
 
 
 
 
sfdcfoxsfdcfox
That's simple. Attempt to create an account without an account name. Since the account name is blank, it will throw an exception since a system-required field is missing.