Reply
Contributor
Armando Guzman
Posts: 3
0
Accepted Solution

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

Trusted Contributor
BSridhar
Posts: 281
0

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

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

Contributor
Armando Guzman
Posts: 3
0

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

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

Trusted Contributor
BSridhar
Posts: 281
0

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

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

Contributor
Armando Guzman
Posts: 3
0

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

Thanks very much