I had issue with deploying some changes to prod. First please note that this contain many changes in some triggers/classes, therefore don't sure if it'll help to post here all the relevant code and debug it, instead I'm trying to find general idea for the source issue.
I upload change set and when trying to validate it, received test class failure. Since the failure couldn't reproduce in sandbox, I searched for setup discrepancies, dependency in deploying user/profile, but found nothing.
Finally, I created new refreshed sandbox to make sure it have the exact same setup as prod, submitted the change set to the new sandbox. During validate I received the same error as in production, so I deployed to this new sandbox without running tests. Then I tried to run the failing test class from console, and surprisingly, it end up without any error.
Anyone have idea what can cause it? Does the test behave different during validation vs running from console? Note, that I disable parallel test execution.
Update: I rolled back the changes manually in the new sandbox. Upload again the change set, and check the following validate options:
- When validate by Running all local test - the problematic test is failing
- when validate by running only this test it is pass (failed due to coverage but no error in the test itself)
- When validate by running the failing test and other random test class - the problematic test is failing.
What am I missing? Still, I disable parallel test execution
The error is:
REQUIRED_FIELD_MISSING, Required fields are missing: [QuoteId]: [QuoteId].
Seems the code try to sync between opportunity to quote but failed, therefore later it try to create quoteLineItem without quoteId.... I tried to focus more on understanding how it all it's possible that it was failing during validation to the new sandbox, but now it's working when running from console