Solution: Use if(!Test.isRunningTest()) {} to skip piece of code.
Example:
public void validate() {
if(!Test.isRunningTest()) {
Account objAccount = new Account();
objAccount.name ='Test Account';
insert objAccount;
}
}
Note: The 3 lines written inside of if loop won't be triggered when associated test class is running.
Example:
public void validate() {
if(!Test.isRunningTest()) {
Account objAccount = new Account();
objAccount.name ='Test Account';
insert objAccount;
}
}
Note: The 3 lines written inside of if loop won't be triggered when associated test class is running.
No comments:
Post a Comment