You need to sign in to do that
Don't have an account?
MarkLevy
Apex Test works in Sandbox but fails in deploy to Production??
This seems to be happening to me now where I have certain tests that work just fine in my Sandbox but fail assertions when deploying to Production thus failing the test. It seems to be happening all of a sudden on certain tests and I have no idea why.
All of my tests use @isTest(seeAllData=false) so there shouldn't be a problem between Sandbox VS. Production data.
This particular test that is failing is an update on a lead that should be updating properly, but the assertion shows that the update failed. I'm creating users in the test as well and using System.runAs so that shouldn't be different between Sandbox and Production either.
In my Production I have it set to run Apex tests one at a time, so that shouldn't be interfering with my tests either.
I really have no idea what's going on here.
Any assistance as to why a test using only test data would work in Sandbox but fail in Production would be helpful.
I could post my code but it's very very long, and it could be something else on the Production server that is causing the check if update worked assertion to fail as well so I can't very well post all the Apex code on my server. The most helpful thing for me would be strategy on what could be wrong and how to go about investigating this further. Is there some specific Lead Update Failed reason in a log somewhere I can look up or something that I can do shed more light on why this is happening?
Thanks!
All of my tests use @isTest(seeAllData=false) so there shouldn't be a problem between Sandbox VS. Production data.
This particular test that is failing is an update on a lead that should be updating properly, but the assertion shows that the update failed. I'm creating users in the test as well and using System.runAs so that shouldn't be different between Sandbox and Production either.
In my Production I have it set to run Apex tests one at a time, so that shouldn't be interfering with my tests either.
I really have no idea what's going on here.
Any assistance as to why a test using only test data would work in Sandbox but fail in Production would be helpful.
I could post my code but it's very very long, and it could be something else on the Production server that is causing the check if update worked assertion to fail as well so I can't very well post all the Apex code on my server. The most helpful thing for me would be strategy on what could be wrong and how to go about investigating this further. Is there some specific Lead Update Failed reason in a log somewhere I can look up or something that I can do shed more light on why this is happening?
Thanks!
I go through the getDmlMessage and put it into the debugStr and then print the debugStr on the assert which is one of the few messages I can see when the deployment fails.
Doing this I discovered that it was failing because of a validation rule. This is very strange though because I have that same validation rule on my Sandbox. Anyway I think that now that I have clearer error messages I can figure this out. Thanks!
All Answers
I go through the getDmlMessage and put it into the debugStr and then print the debugStr on the assert which is one of the few messages I can see when the deployment fails.
Doing this I discovered that it was failing because of a validation rule. This is very strange though because I have that same validation rule on my Sandbox. Anyway I think that now that I have clearer error messages I can figure this out. Thanks!