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 

How to Call test class from trigger??? I want to deploy trigger....

Hi,

 

I have a trigger and i want to deploy it to production... please let me know how can i achieve that. I have both the trigger and test class. This test class covers 100% code coverage if trigger in sandbox.. but fails while deployment and remains with 0% only.

 

Please help me with the following trigger and test class....

 

 

I certainly do not know how 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;  

    }
}

 

 

 

SargeSarge

Hi Sunny,

 

 

  See my post in this thread

 

Hope this helps.