You need to sign in to do that
Don't have an account?
Lukasz Piziak
Deployment failed due to problem with Apex Tests.
Hi,
During deploying my App from sandbox to production environment I have got 1 error message that Apex Test is Failed. I have included the missing field mentioned in Error Message and after another deploying again i'm getting the same failure.
Please see screenshot:
What to do to fix my issue?
Thanks for any help
During deploying my App from sandbox to production environment I have got 1 error message that Apex Test is Failed. I have included the missing field mentioned in Error Message and after another deploying again i'm getting the same failure.
Please see screenshot:
What to do to fix my issue?
Thanks for any help
The issue is with your unit test, not the actual deployment of any custom objects or fields.
In your ChatterAnswersCreateAccountTestvalidateAccountCreation method, you'll need to set a value on "MFG_Account_Number__c" in which ever object you're creating at line 11.
My guess is at some point, your production and sandbox environments became out of sync. Someone set the MFG_Account_Number__c field as required in production, but forgot to set it required in sandbox.
Thank you for a quick reply.
This is what the Error message is containing:
"System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [MFG_Account_Number__c]: [MFG_Account_Number__c]
Stack Trace: Class.ChatterAnswersRegistration.createAccount: line 8, column 1 Class.ChatterAnswersCreateAccountTest.validateAccountCreation: line 11, column 1"
If I change the [MFG_Account_Number__c] field as required in sandbox and then add this again to my change sets it should fixed the problem?
However, this will allow you to fix and to test your fix for the error you are seeging in your ChatterAnswersCreateAccountTest.validateAccountCreation method in sandbox.
I would suggest the following:
Thank you for al your help.
I'm new to Salesforce and some your suggestions are not clear for me.
-
Could you please advise where I should rerun test without any modifications to the test class/method itself?
-
Where in sandbox I should fix test class by setting the MFG_Account_Number__c field ?
-
How to verify if my test class is working properly in sandbox?
My apologies if this is annoying you, but it is my first deploy to production.What I gathered this Apex Class exists in production but is not exist in sandbox.
I reruned the test and result is failed:
Class.ChatterAnswersCreateAccountTest.validateAccountCreation: line 11, column 1
You miss a required field MFG_Account_Number__c in class ChatterAnswerRegistration method createAccount Line 8 AND Class chatterAnswerCreateAccountTest method validateAccountCreation line 11.
Or Please check custom field in prod present or not.
Or You can take help by set debug log in Prod.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Suraj