• Madhusudhan Reddy 11
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
When deploying task trigger it shows Triggers have 0% code coverage

but the same if we deploy through change set and runts the test class it covers 100% any advise on this please suggect 

here is trigger and test class 

trigger TaskTrigger on Task(before insert) {
    
    if(ACNTriggerSettings__c.getInstance(UserInfo.getUserId()).LG_TaskTrigger__c){return;}
    
    TaskTriggerHandler handler = new TaskTriggerHandler(Trigger.isExecuting, Trigger.size);
        if (trigger.isbefore&& trigger.isinsert) {
            handler.beforeinserttrigger(trigger.new,trigger.newMap);
        }
}
========================
test class 
========================

@isTest(SeeAllData = false)
Public class taskTriggerHandlertest{
static testmethod void addTTControllerTest()  {
   
    test.startTest();
            
    //insert new ACNTriggerSettings__c(SetupOwnerId=UserInfo.getUserid(), LG_TaskTrigger__C=false);
            
    Account testAccount = new Account(Name='testAccountM',BillingStreet='TestStreet', BillingCity='Test City', BillingState='State', BillingPostalCode='12345', BillingCountry='UK');
    insert testAccount;
    system.assertEquals('testAccountM', testAccount.Name);

    Contact testContact = new Contact(FirstName = 'TestNameM', LastName = 'TestNameM', Salutation ='Mr.', email = 'test@test.com',AccountId=testAccount.id);
    insert testContact;
    system.assertEquals('TestNameM', testContact.FirstName);

    Opportunity testOpportunity = new Opportunity(amount=500,CloseDate = system.today().addMonths(4),Approval_Stage4_5__c='Not Submitted', Name = 'TestOppM', StageName = 'Quoting', AccountId =testAccount.id );
    insert testOpportunity;
    system.assertEquals('TestOppM', testOpportunity.Name);
    
    CSCAP__Customer_Approval__c TestCustomerapproval = new CSCAP__Customer_Approval__c(CSCAP__Opportunity__c=testOpportunity.id);
    insert TestCustomerapproval ;
    
    task Testtask = new task (Subject='Customer Approval Received',Status='In Progress',Priority='Medium',type='Other',whatid=TestCustomerapproval.id,OwnerId = UserInfo.getUserid());
    insert Testtask ;
   
    test.stopTest();

}
}

 
When deploying task trigger it shows Triggers have 0% code coverage

but the same if we deploy through change set and runts the test class it covers 100% any advise on this please suggect 

here is trigger and test class 

trigger TaskTrigger on Task(before insert) {
    
    if(ACNTriggerSettings__c.getInstance(UserInfo.getUserId()).LG_TaskTrigger__c){return;}
    
    TaskTriggerHandler handler = new TaskTriggerHandler(Trigger.isExecuting, Trigger.size);
        if (trigger.isbefore&& trigger.isinsert) {
            handler.beforeinserttrigger(trigger.new,trigger.newMap);
        }
}
========================
test class 
========================

@isTest(SeeAllData = false)
Public class taskTriggerHandlertest{
static testmethod void addTTControllerTest()  {
   
    test.startTest();
            
    //insert new ACNTriggerSettings__c(SetupOwnerId=UserInfo.getUserid(), LG_TaskTrigger__C=false);
            
    Account testAccount = new Account(Name='testAccountM',BillingStreet='TestStreet', BillingCity='Test City', BillingState='State', BillingPostalCode='12345', BillingCountry='UK');
    insert testAccount;
    system.assertEquals('testAccountM', testAccount.Name);

    Contact testContact = new Contact(FirstName = 'TestNameM', LastName = 'TestNameM', Salutation ='Mr.', email = 'test@test.com',AccountId=testAccount.id);
    insert testContact;
    system.assertEquals('TestNameM', testContact.FirstName);

    Opportunity testOpportunity = new Opportunity(amount=500,CloseDate = system.today().addMonths(4),Approval_Stage4_5__c='Not Submitted', Name = 'TestOppM', StageName = 'Quoting', AccountId =testAccount.id );
    insert testOpportunity;
    system.assertEquals('TestOppM', testOpportunity.Name);
    
    CSCAP__Customer_Approval__c TestCustomerapproval = new CSCAP__Customer_Approval__c(CSCAP__Opportunity__c=testOpportunity.id);
    insert TestCustomerapproval ;
    
    task Testtask = new task (Subject='Customer Approval Received',Status='In Progress',Priority='Medium',type='Other',whatid=TestCustomerapproval.id,OwnerId = UserInfo.getUserid());
    insert Testtask ;
   
    test.stopTest();

}
}