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 

URGENT: Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

Hi Sir,


I have created an apex test class the covers four trigger named: (1) updaterequestowner (2) change_opps (3) initialstage (4) previousstage . After doing Run All Test i have the following code coverage for the following trigger. Although all of them are more than 1%.


Trigger Name                           Coverage %

UpdateResourceReqDates  75

DefaultTitle                               50

updaterequestowner             100

AccountDuplicateTrigger       80

ContactDuplicateTrigger      100

change_opps                          66

initialstage                              100

previousstage                         75





But when i try deploying them in production an error appears for each of the trigger. However in sandbox it shows more than 1%.



previousstage   Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required
updaterequestowner   Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required
initialstage   Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required


Here, is the test class:



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




am i missing something else?? please help...its very urgent...


Make sure you are including your test class in your deployment.




I am also having the same problem. I'm not sure if the original poster solved this, if so I would be happy if they would share the solution. I have a single trigger I am trying to implement using Eclipse like the reply suggests I have a test method for it in a seperate class. I run the tests and they both get 100% coverage according to Eclipse (also ran all tests in Developer Edition and got 100% there too). Then when I go to deploy both class and trigger to the server, I get 100% coverage for the class but 0% for the trigger. I have no idea why.


Another problem that is occuring at the same time is errors coming from a Chatter related class or trigger (ChatterConnector as far as I remember) as well as some low coverage on some of it's classes. It is claiming that there is only a total of 72% coverage overall which I assume would be only because of my trigger having 0% and pulling the average down. Could it be these Chatter related problems could be stopping the deployment of my trigger?


Here is my code anyway incase that may be the problem:




trigger triggerLeadConvertIncludeSponsor on Lead (before update) {
    for(Lead {
        if (lead.IsConverted) {
            Computers__c comp = [SELECT Id, Sponsor__c, Afritrack_Number__c FROM Computers__c WHERE Computers__c.Afritrack_Number__c = :lead.Tracking_Number__c];
            comp.Sponsor__c = lead.ConvertedContactId;
            update comp;

public class leadConvertIncludeSponsor {
    public static testMethod void includeSponsor() {
    Lead leadA = new Lead();
    leadA.lastname = 'Test Lead A'; = 'Test company';
    leadA.status = 'Open'; = '';
    leadA.Tracking_Number__c = '12345/d';
    insert leadA;
    Database.LeadConvert lc = new database.LeadConvert();

    LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];

    Database.LeadConvertResult lcr = Database.convertLead(lc);



Any help on this would be much appreciated.