+ Start a Discussion
LBartonLBarton 

Can't Deploy an Apex Trigger

I can't deploy my trigger because there is an error in an Apex class and its corresponding test class. Actually it may just be in the test class.  In fact, I can't deploy anything but I want to change the test class so that it won't get an error!

 

I have been using the Eclpse IDE to deploy.  This really isn't a matter of deploying from the "sandbox" to the Production environment since this already exits in Production.  I am not sure where to begin.

werewolfwerewolf

Well, the first step is to run the test (either by navigating to its class in Setup and clicking Run Tests or by running tests in the Force.com IDE), look at the error, and see if you can fix it.  Running the test will produce a log that you can eyeball, and the error will be in there. The error may be in the trigger or it may be in the test, but in either case it's trying to tell you something important.

LBartonLBarton

 My trigger works in the Sandbox and its test class has 100% coverage. 

 

I know exactly what is wrong with a class in the production environment.  I have run the tests.  The test for a TestClass (for a class I did not create) has failed but I can’t fix the test class.  I can’t do any deploying of anything.  The problem in the test class is that there is a system.exception:  to many rows:501.  I can't fix the test class that has the error since I can't deploy but that is already in production.  Is this a Catch-22 type of situation?  I can't deploy so I can't fix something that is deployed?  I am using Eclipse.

 

 

 

 

JonPJonP

If you deploy all the changed files together in a single transaction, including the fix to your test, the tests will run and (if the fixes all worked) pass.

LBartonLBarton

No, it still won't work, but thanks!  I did that.

JonPJonP

As long as any test is failing you won't be able to deploy, so you either need to fix that test created by someone else, or find the owner and get him or her to fix it.

ilewi121ilewi121
Did anyone figure out how to do correct this? I am stuck with a previously deployed trigger that now has a failed test. I updated in the sandbox, but can't deploy the changes, because it fails in production.