+ Start a Discussion
SFDCDevQASFDCDevQA 

Trouble updating/deploying an apex class

I am having trouble deploying an apex class from my sandbox to my production.  Everything in the sandbox works fine but when I try to deploy it from eclipse I get a Failures and Warnings screen.  My apex class is called ProductstoAssets and an image of the error I am receiving is attached.  Someone please help!  It's driving me nuts that I finally got this working right in the sandbox and now I can't get it moved over to production.  If you need the debug log I can post it in sections.

 

eclipseerror

Best Answer chosen by Admin (Salesforce Developers) 
Jeremy_nJeremy_n

So you have a system.assert referring to OID or AID on line 367 of your testclass that is failing.

 

First, please post the section of code this refers to, and maybe we can narrow down what the problem is.

 

Since it worked in sandbox but not production, I would guess that something is different in configurations. I would sprinkle system.debug statements all over your code, to see why your assertion is failing. Things I would look for in the debug log:

-- Hardcoded IDs. Any IDs in your Apex code may not work in other instances of Salesforce

-- Using existing data for testing, rather than creating it all from scratch in your testmethod. If you are querying for existing objects to use for testing, are you sure there are existing records that meet your query requirements?

-- Differences in Classes or Triggers, object configuration, validation rules, workflow rules, field definitions etc. Anything that's been created or changed in production since that sandbox was refreshed will not be reflected in the sandbox environment.

 

Let us know what you find!

 

Jeremy

All Answers

Jeremy_nJeremy_n

So you have a system.assert referring to OID or AID on line 367 of your testclass that is failing.

 

First, please post the section of code this refers to, and maybe we can narrow down what the problem is.

 

Since it worked in sandbox but not production, I would guess that something is different in configurations. I would sprinkle system.debug statements all over your code, to see why your assertion is failing. Things I would look for in the debug log:

-- Hardcoded IDs. Any IDs in your Apex code may not work in other instances of Salesforce

-- Using existing data for testing, rather than creating it all from scratch in your testmethod. If you are querying for existing objects to use for testing, are you sure there are existing records that meet your query requirements?

-- Differences in Classes or Triggers, object configuration, validation rules, workflow rules, field definitions etc. Anything that's been created or changed in production since that sandbox was refreshed will not be reflected in the sandbox environment.

 

Let us know what you find!

 

Jeremy

This was selected as the best answer
EIE50EIE50

Hi,

 

If you are on a time constraint, try doing this though this is not a good practise. Comment out the system.assert's in your test classes and enclose the methods in try catch block.

 

I would recommend to follow jermy's steps in the previous reply.

 

Thanks.