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
devloper sfdcdevloper sfdc 

Test class running successfully but apex class code coverage None

Hi All

I write test class it is running successfully but apex class code coverage is none .
i am mention class and test class please help me.

public class Case_Automated_Escalation_MidState{
    
   public static void beforeTriggerCall(List<Case> listCase){
    
        for(Case cs : listCase){
            String queueName = manageQueueName(cs);
            if(UtilityController.mapQueue.containsKey(queueName)){
                cs.Status = 'Escalated';
                cs.OwnerId = UtilityController.mapQueue.get(queueName);
            }
        }
    }
    
    private static String manageQueueName(Case cs){
        String queueName = '';
       
    /*----------------------------------------------------------------------MidState - Media Services-------------------------------------------------------------------------------*/ 
        
        if(cs.Ticket_Category2__c=='Digital Storefront'||cs.Ticket_Category2__c=='Printing' &&((cs.Ticket_Type2__c=='Troubleshoot (Printing / Imaging)' && (cs.Ticket_Item2__c!='Software / Configuration')) ||(cs.Ticket_Type2__c=='Setup / Configuration (Printing / Imaging)' && (cs.Ticket_Item2__c!='Connecting to an existing printer')))&& cs.Status=='Action - Automated Escalation'){
            
            queueName='MidState - Media Services';
        }
        
    
  /*-------------------------------------------------------------------MidState - Desktop Services---------------------------------------------------------------------------*/    
        if((cs.Ticket_Category2__c=='Software (Computer)'||cs.Ticket_Category2__c=='Mobile Device - Mid-State Owned'|| cs.Ticket_Category2__c=='Email' && cs.Ticket_Type2__c=='Troubleshoot (Email)' ) && cs.Status=='Action - Automated Escalation'){
         
            queueName='MidState Dsktop Services';  
        }
        
        if((cs.Ticket_Category2__c=='Computers and Classroom Technology' &&((cs.Ticket_Type2__c=='Install  / Configuration' || cs.Ticket_Type2__c=='Troubleshoot')&&(cs.Ticket_Item2__c=='Desktop Computer'||cs.Ticket_Item2__c=='Desktop Monitor'||cs.Ticket_Item2__c=='Wired Mouse'||cs.Ticket_Item2__c=='Wired Keyboard' ))||
       (cs.Ticket_Type2__c=='Move/Add/Change (Computer)'&& cs.Ticket_Item2__c=='Hardware')|| cs.Ticket_Type2__c=='Imaging'||cs.Ticket_Type2__c== 'Other')&& cs.Status=='Action - Automated Escalation'){
             queueName='MidState Dsktop Services';  
           }
        
        if(cs.Ticket_Category2__c=='Network' &&(cs.Ticket_Type2__c=='VPN / Remote Access'||cs.Ticket_Type2__c=='Wireless'||cs.Ticket_Type2__c=='Troubleshoot (Network)')
           &&(cs.Ticket_Item2__c=='Troubleshoot (Network)' || cs.Ticket_Item2__c=='Setup '||cs.Ticket_Item2__c=='Troubleshoot'||cs.Ticket_Item2__c=='Wireless'||cs.Ticket_Item2__c=='VPN / Remote Access') && cs.Status=='Action - Automated Escalation'){
             queueName='MidState Dsktop Services'; 
              
           }
        if((cs.Ticket_Category2__c=='Printing'&& cs.Ticket_Type2__c=='Setup / Configuration (Printing / Imaging)' && cs.Ticket_Item2__c=='Connecting to an existing printer') && cs.Status=='Action - Automated Escalation'){
            queueName='MidState Dsktop Services'; 
        }
     /*------------------------------------------------------------------------------MidState - Network Services--------------------------------------------------------------------------*/    
       
        if(cs.Ticket_Category2__c=='Email' && (cs.Ticket_Type2__c=='Login'||cs.Ticket_Type2__c=='Access / Permissions (MS)'||cs.Ticket_Type2__c=='Setup / Configuration (Email)'||(    cs.Ticket_Type2__c=='Troubleshoot (Email)'&& cs.Ticket_Item2__c!='Email - Outlook/365'))&& cs.Status=='Action - Automated Escalation')
        {
          queueName ='MidState - Network Services';   
        }
        
        if((cs.Ticket_Category2__c=='ImageNow (Perceptive Content)'||(cs.Ticket_Category2__c=='Outage'&& cs.Ticket_Type2__c=='Email')||(cs.Ticket_Category2__c=='Printing' && cs.Ticket_Type2__c=='Troubleshoot (Printing / Imaging)'&& cs.Ticket_Item2__c=='Software / Configuration')) &&  cs.Status=='Action - Automated Escalation' ){
            queueName ='MidState - Network Services'; 
        }
        
        if(cs.Ticket_Category2__c=='Network'&& (cs.Ticket_Type2__c=='File Maintenance'||cs.Ticket_Type2__c=='Login (Network)'||cs.Ticket_Type2__c=='Other' ||(cs.Ticket_Type2__c=='VPN / Remote Access'&& cs.Ticket_Item2__c=='Setup / Configuration (Network)')||(cs.Ticket_Type2__c=='Setup / Configuration (Network)'&& cs.Ticket_Item2__c=='VPN / Remote Access')
           ||(cs.Ticket_Type2__c=='Troubleshoot (Network)'&& cs.Ticket_Item2__c=='File Maintainance'))&& cs.Status=='Action - Automated Escalation')
        {
            queueName ='MidState - Network Services'; 
            
        }
        
          if((cs.Ticket_Category2__c=='Portal  (MidState)' && cs.Ticket_Type2__c=='MyCampus')&& cs.Status=='Action - Automated Escalation')
          {
            queueName='MidState - Network Services';
        }       
        
        if((cs.Ticket_Category2__c=='Outage' && cs.Ticket_Type2__c=='MyCampus Portal') && cs.Status=='Action - Automated Escalation')
        {
            queueName='MidState - Network Services'; 
            
        }
            
            /*-----------------------------------------------------------------------------MidState - Network Infrastructure-----------------------------------------------------------------*/    
          if(cs.Ticket_Category2__c=='Network/Services' ||(cs.Ticket_Category2__c=='Outage' && (cs.Ticket_Type2__c=='Power'||cs.Ticket_Type2__c=='Telephone'||(cs.Ticket_Type2__c=='Network'&& (cs.Ticket_Item2__c=='Wired'||cs.Ticket_Item2__c=='Wireless'))))&& cs.Status=='Action - Automated Escalation' )
                  {
                    queueName ='MidState - Network Infrastructure';  
                 }
        
        
                if(cs.Ticket_Category2__c=='Network' && (cs.Ticket_Type2__c=='Setup/ Troubleshoot (Network)' && cs.Ticket_Item2__c=='Network Drops /Installation') && cs.Status=='Action - Automated Escalation')
                 {
                   queueName ='MidState - Network Infrastructure';
                  }
        
        if(cs.Ticket_Category2__c=='Network' && ((cs.Ticket_Type2__c=='Troubleshoot (Network)')&& (cs.Ticket_Item2__c=='Wired'|| cs.Ticket_Item2__c=='Wireless AP /Devices'|| cs.Ticket_Item2__c=='Internet /WILM Connectivity'||
            cs.Ticket_Item2__c=='Video Conferencing /LTC/NWTC'|| cs.Ticket_Item2__c=='Video Surveillance /Campus'|| cs.Ticket_Item2__c=='Card Access/Door Schedules/keypads'||
            cs.Ticket_Item2__c=='Video Surveillance /Testing Centers'||cs.Ticket_Item2__c=='Digital Display /Digital Marquees' ||cs.Ticket_Item2__c=='Digital Display /Digital Marquees'))&& cs.Status=='Action - Automated Escalation')
           {
           queueName ='MidState - Network Infrastructure';                                           
            }

        
        /*--------------------------------------------------------------------------------MidState - Telephony----------------------------------------------------------------------------*/   
        if((cs.Ticket_Category2__c=='Phone System'|| cs.Ticket_Category2__c=='Phone System/Services') && cs.Status=='Action - Automated Escalation')
        {
            
            queueName='MidState - Telephony';
        }
        
        
        
        /*-------------------------------------------------------------------MidState - Classroom Instructional Technology------------------------------------------------------------------------------*/    
        if(cs.Ticket_Category2__c=='Computers and Classroom Technology' && (cs.Ticket_Type2__c=='Classroom EMERGENCY')&& cs.Status=='Action - Automated Escalation')
        {
        queueName='MidState - Classroom Instructional Tech';     
        }
        
       if(cs.Ticket_Category2__c=='Computers and Classroom Technology' && ((cs.Ticket_Type2__c=='Install  / Configuration'||cs.Ticket_Type2__c=='Troubleshoot') && (cs.Ticket_Item2__c=='Document Camera'||cs.Ticket_Item2__c=='Microphone'||cs.Ticket_Item2__c=='Projector'||cs.Ticket_Item2__c=='Projector Screen'
            ||cs.Ticket_Item2__c=='Interactive screen/monitor'||cs.Ticket_Item2__c=='Speakers/Amplifier'||cs.Ticket_Item2__c=='Monitor/Television'||cs.Ticket_Item2__c=='Printer'||cs.Ticket_Item2__c=='Telepresence'||cs.Ticket_Item2__c=='AV Conferencing'||cs.Ticket_Item2__c=='Wireless Mouse'||
           cs.Ticket_Item2__c=='Wireless Keyboard'||cs.Ticket_Item2__c=='Conferencing camera')) && cs.Status=='Action - Automated Escalation')
          {
         queueName='MidState - Classroom Instructional Tech';    
          }
        
        
         if(cs.Ticket_Category2__c=='Computers and Classroom Technology' && (cs.Ticket_Type2__c=='Troubleshoot' && (cs.Ticket_Item2__c=='Document Camera'||cs.Ticket_Item2__c=='Microphone'||cs.Ticket_Item2__c=='Projector'||cs.Ticket_Item2__c=='Projector Screen'||cs.Ticket_Item2__c=='AV Conferencing'||cs.Ticket_Item2__c=='Wireless Mouse'||cs.Ticket_Item2__c=='Wireless Keyboard'||cs.Ticket_Item2__c=='Conferencing camera')) && cs.Status=='Action - Automated Escalation')
          {
         queueName='MidState - Classroom Instructional Tech';    
          }
        
            
         if(cs.Ticket_Category2__c=='Outage' && cs.Ticket_Type2__c=='Telepresence'  && cs.Status=='Action - Automated Escalation')
         {
            
            queueName='MidState - Classroom Instructional Tech';
        }

   /*-----------------------------------------------------------------------MidState - Online Instructional Tech-----------------------------------------------------------------*/
               
        
        if(cs.Ticket_Category2__c=='Outage' && cs.Ticket_Type2__c=='Blackboard'  && cs.Status=='Action - Automated Escalation')
        {
            
            queueName='MidState - Online Instructional Tech';
        }
        
       
        if(cs.Ticket_Category2__c=='Blackboard' && (cs.Ticket_Type2__c=='Login'|| cs.Ticket_Type2__c=='Access / Permissions'|| cs.Ticket_Type2__c=='Instructor (LMS)'|| cs.Ticket_Type2__c=='Student (LMS)')&& cs.Status=='Action - Automated Escalation')
        {
            
            queueName='MidState - Online Instructional Tech';
        }
        
        
        
        /*-------------------------------------------------------------------------------------------Misslenius CTI------------------------------------------------------------------*/  
        
        if((cs.Ticket_Category2__c=='Network' && (cs.Ticket_Type2__c=='Setup / Configuration  (Network)' && cs.Ticket_Item2__c=='VPN / Remote Access')) && cs.Status=='Action - Automated Escalation')
        {
           queueName ='MidState - Network Services';   
            
        }
         
        if(cs.Ticket_Category2__c=='Network' && cs.Ticket_Type2__c=='Setup / Configuration  (Network)' && cs.Ticket_Item2__c=='Wireless' && cs.Status=='Action - Automated Escalation')
        {
           queueName ='MidState Dsktop Services';   
            
        }
                
         if(cs.Ticket_Category2__c=='Network' && (cs.Ticket_Type2__c=='Setup / Configuration  (Network)' && (cs.Ticket_Item2__c=='Wired' || cs.Ticket_Item2__c=='Wireless AP /Devices')) && cs.Status=='Action - Automated Escalation')
        {
           queueName ='MidState - Network Infrastructure';   
            
        }
        
        
        
        /*----------------------------------------------------------------------------MidState - Student Records----------------------------------------------------------------*/    
        if(((cs.Ticket_Category2__c=='Portal  (MidState)' && cs.Ticket_Type2__c=='MyMSTC')|| cs.Ticket_Category2__c== 'Registration'|| (cs.Ticket_Category2__c=='Outage' && cs.Ticket_Type2__c=='MyMSTC (Outage)'))&& cs.Status=='Action - Automated Escalation'){
            queueName='MidState - Student Records';
        }
        
        
       return queueName;       
     }
}


and test class is 


@isTest
public class TestCase_Automated_escalation_Midstate {
     // test method
    @isTest
    private static void test(){
        
        /*Group queuename=[select Id from Group where Name = 'MidState - Classroom Instructional Tech' and Type = 'Queue'];*/
        // create test account
        Account acc = TestUtilityController.getAccount('Mid-State Technical College');
        insert acc; 
        
        // create test contact
        Contact con = TestUtilityController.getContact('Test Last Name','testing@testing.com',acc.Id);
        insert con;
        
        // fill utility
        UtilityController.fillUtilities();
        UtilityController.isUtility = false;
        
        // Create test cases
        List<Case> listCase = new List<Case>();
        
        if(UtilityController.caseRecordType.containsKey('Mid-State Technical College_Ticket')){
            String recordTypeId = UtilityController.caseRecordType.get('Mid-State Technical College_Ticket').Id;
             Case csa = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa.Status = 'Action - Automated Escalation';
            csa.Ticket_Category2__c = 'Digital Storefront';
            csa.Ticket_Type2__c = 'Printing';
              listCase.add(csa);
             
            Case csa1 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa1.Status = 'Action - Automated Escalation';
            csa1.Ticket_Category2__c = 'Outage';
            csa1.Ticket_Type2__c = 'Blackboard';
            
             listCase.add(csa1);
            
             Case csa2 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa2.Status = 'Action - Automated Escalation';
            csa2.Ticket_Category2__c = 'Software (Computer)';
            csa2.Ticket_Type2__c = 'Troubleshoot (Email)';
            
            listCase.add(csa2);
            
             Case csa3 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa3.Status = 'Action - Automated Escalation';
            csa3.Ticket_Category2__c = 'Computers and Classroom Technology';
            csa3.Ticket_Type2__c = 'Install  / Configuration';
            csa3.Ticket_Item2__c='Desktop Monitor';
            listCase.add(csa3);
            
             Case csa4 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa4.Status = 'Action - Automated Escalation';
            csa4.Ticket_Category2__c = 'Network';
            csa4.Ticket_Type2__c = 'VPN / Remote Access';
            csa4.Ticket_Item2__c='Troubleshoot (Network)';
            
            listCase.add(csa4);
            
             Case csa5 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa5.Status = 'Action - Automated Escalation';
            csa5.Ticket_Category2__c = 'Printing';
            csa5.Ticket_Type2__c = 'Setup / Configuration (Printing / Imaging)';
            csa5.Ticket_Item2__c= 'Connecting to an existing printer';
            listCase.add(csa5);
            
             Case csa6 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa6.Status = 'Action - Automated Escalation';
            csa6.Ticket_Category2__c = 'Portal';
            csa6.Ticket_Type2__c = 'Troubleshoot (Email)';
            listCase.add(csa6);
            
             Case csa7 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa7.Status = 'Action - Automated Escalation';
            csa7.Ticket_Category2__c = 'ImageNow (Perceptive Content)';
            csa7.Ticket_Type2__c = 'Email';
            listCase.add(csa7);
            
             Case csa8 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa8.Status = 'Action - Automated Escalation';
            csa8.Ticket_Category2__c = 'Network';
            csa8.Ticket_Type2__c = 'Login (Network)';
            
            listCase.add(csa8);
            
             Case csa9 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa9.Status = 'Action - Automated Escalation';
            csa9.Ticket_Category2__c = 'Network/Services';
            csa9.Ticket_Type2__c = 'Power';
            
            listCase.add(csa9);
            
             Case csa10 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa10.Status = 'Action - Automated Escalation';
            csa10.Ticket_Category2__c = 'Network';
            csa10.Ticket_Type2__c = 'Troubleshoot (Network)';
            
            listCase.add(csa10);
            
             Case csa11 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa11.Status = 'Action - Automated Escalation';
            csa11.Ticket_Category2__c = 'Phone System';
                         
            listCase.add(csa11);
            
              Case csa12 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa12.Status = 'Action - Automated Escalation';
            csa12.Ticket_Category2__c = 'Registration';
            csa12.Ticket_Type2__c = 'MyMSTC';
            
            listCase.add(csa12);
            
            
             Case csa13 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa13.Status = 'Action - Automated Escalation';
            csa13.Ticket_Category2__c = 'Computers and Classroom Technology';
            csa13.Ticket_Type2__c = 'Move/Add/Change (Computer)';
            csa13.Ticket_Item2__c='Hardware';
            listCase.add(csa13);
            
             
             Case csa14 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa14.Status = 'Action - Automated Escalation';
            csa14.Ticket_Category2__c = 'Computers and Classroom Technology';
            csa14.Ticket_Type2__c = 'Install  / Configuration';
            csa14.Ticket_Item2__c='Speakers/Amplifier';
            listCase.add(csa14);
            
            
             Case csa15 = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
            csa15.Status = 'Action - Automated Escalation';
            csa15.Ticket_Category2__c = 'Computers and Classroom Technology';
            csa15.Ticket_Type2__c = 'Troubleshoot';
            csa15.Ticket_Item2__c='Document Camera';
            listCase.add(csa15);
            
insert listCase;
}
    }
}
Jason Lim 13Jason Lim 13
Hello, is that a helper class for trigger ? anyway you should be able to invoke it directly in test class ->

Case_Automated_Escalation_MidState.beforeTriggerCall(listCase);