You need to sign in to do that
Don't have an account?

Unable to deploy Apex Triggers
Hi all,
I've been working with Apex triggers in a development environment but I'm unable to deploy them to a production environment. I have been able to deploy Apex classes with their respective testMethods but am unable to deploy the Triggers.
I created a trigger on an Opportunity and created a testMethod in an Apex class, however it does not appear as though the test is working.
I've even tried to deploy the LeadDupeTrigger from the Apex Cookbook - and the tests don't appear to be running. (Again the tests with just Apex Classes work fine).
The Code Coverage Results say:
myTriggerTester (Class) - 0 Lines not tested, 100% covered
However, the debug log (set to max verbosity) displays the following:
I created a simple trigger to test deployment, it is below:
And the testMethod:
I've been working with Apex triggers in a development environment but I'm unable to deploy them to a production environment. I have been able to deploy Apex classes with their respective testMethods but am unable to deploy the Triggers.
I created a trigger on an Opportunity and created a testMethod in an Apex class, however it does not appear as though the test is working.
I've even tried to deploy the LeadDupeTrigger from the Apex Cookbook - and the tests don't appear to be running. (Again the tests with just Apex Classes work fine).
The Code Coverage Results say:
myTriggerTester (Class) - 0 Lines not tested, 100% covered
However, the debug log (set to max verbosity) displays the following:
Code:
Debug Log: Cumulative profiling information: No profiling information for SOQL operations. No profiling information for SOSL operations. No profiling information for DML operations. No profiling information for method invocations.
I created a simple trigger to test deployment, it is below:
Code:
trigger populateDates on Opportunity (before insert, before update) { Opportunity [] opp = Trigger.new; for (Integer i = 0; i < opp.size(); i++) { opp[i].Arrival_Date__c = date.today(); } }
And the testMethod:
Code:
public class myTriggerTester { static testMethod void TEST_populateDates() { Account testAccount = new Account ( Name = 'Testing' ); insert testAccount; Opportunity firstOpp = new Opportunity ( Name = 'Test', Account = testAccount, CloseDate = date.today(), StageName = 'Strong Potential', Proposal_Deadline__c = date.today() ); System.assertEquals(null, firstOpp.Arrival_Date__c); insert firstOpp; System.assertEquals(date.today(), firstOpp.Arrival_Date__c); } }
What development environment are you using? If you're using Eclipse, then you start the test by right-clicking the Test class and choosing Force.com -> Run Tests.
You can also choose this command by right-clicking the "classes" folder, which will run ALL tests.
In your tests, you'll probably need to retreive a new copy of the object you created before you can test the field values. Something like:
See how all that goes!