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
KR_ForceKR_Force 

how to get around with Test.isRunningTest() && Limits.getFutureCalls() >= Limits.getLimitFutureCalls() In test class

  1. trigger MasterTrigger on Master__c (before delete, after insert) {
  2.  
  3.     if( trigger.isAfter){
  4.         TriggerHandler.SummaryRecords( trigger.new );
  5.     }
  6.     if(trigger.isBefore && trigger.isDelete){
  7.           if(Test.isRunningTest() && Limits.getFutureCalls() >= Limits.getLimitFutureCalls()){
  8.            system.debug(LoggingLevel.Error, 'Future method limit reached. Skipping...');
  9.          }
  10.        else {BUtil.DeleteService(trigger.oldMap.keySet());}
  11.            
  12.         }
  13. }Trigger
Not able to get around with line number line number and 10 due to that code coverage is not reaching the 75%, Can anyone suggest the trick to pass the through the if condition?
Deepak Kumar ShyoranDeepak Kumar Shyoran
Please try by modifying your condition as mentioned below.
if(Test.isRunningTest() ||( Limits.getFutureCalls() >= Limits.getLimitFutureCalls())){
   system.debug(LoggingLevel.Error, 'Future method limit reached. Skipping...');
        }

And you don't need to cover 75% test coverage for Trigger Salesforce expect to have at least 1% code coverage for Trigger.

bob_buzzardbob_buzzard
This looks to me like you aren't executing a test that will invoke the before delete scenario for that trigger - the isBefore && isDelete condition is covered, which implies that test is executed, but none of the code afterwards.   Do you have a test in place that deletes a Master__c record?