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
Sunny GSunny G 

Pls help > How to achieve minimum 1% code coverage for the trigger?????

Hi All,

 

I certainly do not know how do do that. Please help me with one trigger and class.. like i have the following trigger:

 

trigger updaterequestowner on Pre_Sales_Request__c​ (before insert)
{

       Profile auth_profile = [select id from prof​ile where name='HS_StandardUser_Presales'];       ​   
       Id v_User = UserInfo.GetProfileId();
      for(Pre_Sales_Request__c ob : Trigger.new)
        {          
            if(v_User !=  auth_profile.Id)       
                {
                   ob.Request_Owner__c =  Userinfo​.getUserId(); 
                }
        }                           
}

 

and i have the following test class :

 

@isTest

private class TriggerTests {
            
    public static testmethod void testTrigger() {
       Pre_Sales_Request__c psrc=new Pre_Sales_R​equest__c( name = 'a' );
       insert psrc;
       psrc.name = 'b';
       update psrc;  

    }
}

 

 

How to go to achive the code coverage while deployment, i.e. how to push test class from my trigger??  

aalbertaalbert

Check out this introductory article on test methods.