+ Start a Discussion
Armando GuzmanArmando Guzman 

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

Hi Guys

 

I got this error when i tray to deploy a small triger i created, seem works fine in sanbox

any ideas

 

The code is:

 

1
2
3
4
5
6
7
8
9
10

trigger Update_region on Account (before insert, before update) {
for (Account a : Trigger.new) {
  Region__c[] rgs = [Select Id, state__c From Region__c Where postal_code__c =:a.BillingPostalCode Limit 1];
  if (rgs.size()!=0){
        a.Region__c = rgs[0].Id;
        a.Post_code_del__c = rgs[0].state__c;
         }
        
     }
 }

Thanks in advance

Best Answer chosen by Admin (Salesforce Developers) 
Sridhar BonagiriSridhar Bonagiri

Hi,

 

Please go through the below site for more details on writing test classes for triggers.

 

 

http://teachmesalesforce.wordpress.com/2011/05/07/how-to-write-a-trigger-test/

 

 

Regards,

Sridhar Bonagiri

All Answers

Sridhar BonagiriSridhar Bonagiri

Hi,

 

I think you are getting this error while you are deploying this trigger to the production org from sandbox. If it is yes then you need to write a test class for this trigger to the test coverage. In SFDC you need to cover the code through test classes.

 

 

Regards,

Sridhar Bongiri

Armando GuzmanArmando Guzman

Thanks mate, well I was readding about the classes (btw I am new in this) and I can't make this possible, any additional help?? Thanks

Sridhar BonagiriSridhar Bonagiri

Hi,

 

Please go through the below site for more details on writing test classes for triggers.

 

 

http://teachmesalesforce.wordpress.com/2011/05/07/how-to-write-a-trigger-test/

 

 

Regards,

Sridhar Bonagiri

This was selected as the best answer
Armando GuzmanArmando Guzman

Thanks very much