You need to sign in to do that
Don't have an account?
CK_Young123
System.assertEquals(false, updateDB(fList ));
}
}
can someone help me to test the Exception?
global class tt {
WebService static Boolean updateDB(Account[] fList) {
Boolean updateFlg = true;
WebService static Boolean updateDB(Account[] fList) {
Boolean updateFlg = true;
try{
Database.SaveResult[] SR = Database.update(fList,false);
Database.SaveResult[] SR = Database.update(fList,false);
for(Database.SaveResult lsr:SR){
if(!lsr.isSuccess()){
updateFlg = false;
break;
}
}
}catch (Exception e) {
updateFlg = false;
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';
}
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
sfdcfox
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.