+ Start a Discussion
SandrineSandrine 

Code coverage for trigger on Production fails

I have a simple test class which has sufficient code coverage for Trigger in Partiel Sandbox.
I have 0 % Test coverage in Production.

I have executed the lines individually in Anonymous mode , the code executes properly without any issues.

While deploying i am using : Use specific test and not the default one to test only on test class and the trigger responsible
@isTest(SeeAllData=true) 
private class TestClassTest {
    
    Static testmethod void mytest1 () {
        
        Candidat__c c = new Candidat__c(name='z1', FirstName__c='t1', Email__c = 'test1@test.sf');
        insert c; 

        task e = new task (subject='zz1',whatid=c.id);      
        insert e;
    }

}

Any reason for my usecase ?
Best Answer chosen by Sandrine
Niraj Kumar 9Niraj Kumar 9
Hi Sandrine,
Can you plaese post the trigger?

Thanks
Niraj Kumar

All Answers

Niraj Kumar 9Niraj Kumar 9
Hi,

Please try with below code.
 
@isTest(SeeAllData=true) 
private class TestClassTest {
    
    Static testmethod void mytest1 () {
        test.starttest();
        Candidat__c c = new Candidat__c(name='z1', FirstName__c='t1', Email__c = 'test1@test.sf');
        insert c; 

        Task tsk=new Task();
          tsk.WhatId =c .Id;
          tsk.Status='Completed';
          tsk.Priority='Medium';
          tsk.Subject='zz1';
          tsk.Type = 'Client Meeting';
          insert tsk;
      test.stoptest();
    }

}

Hope this test class will help you.

Thanks
Niraj
SandrineSandrine
Hi Niraj,

the result is still the same
Niraj Kumar 9Niraj Kumar 9
Hi Sandrine,
Can you plaese post the trigger?

Thanks
Niraj Kumar
This was selected as the best answer