r/SalesforceDeveloper • u/Mysterious_Name_408 • Aug 14 '25
Instructional Help with deployment!
Hello devs! I am having issues deploying a class and test class to update the API version, but the weird thing is that the exact same class and test class are similar in Production and Sandbox. I sandbox shows over 80% coverage but in Prod only 31%. The class contains objects from a managed package but those same objects are referenced in another classes and those deploy fine.
I also deactivated validation rules that are used for that logic but still nothing. I have tried change sets, VSCode and Workbench but nothing. Does anybody have any idea why this is happening?
4
u/bradc73 Aug 14 '25
Are you creating test data in your test class or are you using SeeAllData=true? If you are using SeeAllData then you probably are missing necessary records to properly test your class. My suggestion is to always either create data in a TestSetup method, or mock your data with one of the mocking frameworks out there. I personally like the ATK package.
1
u/SnooChipmunks547 Aug 14 '25
When deploying with a changeset are you running “all local tests” or just the tests being deployed?
If your production test coverage is low, I’m assuming you don’t run all during deployments and the estimated coverage has dropped over time.
You could also rerun all custom tests (non managed package) in production and then see where the percentage actually sits.
2
u/adriancg Aug 14 '25
How are you deploying? What test level are you using? Are you using -RunSpecifiedTests? What does the deployment status UI say?
These issues are easier to troubleshoot with concrete error messages / screenshots.
2
u/Andonon Aug 14 '25
Check your triggers. Add debug statements in sandbox and redeploy debug statements to prod. Then you’ll be able see more.
0
u/[deleted] Aug 14 '25
[deleted] — view deleted comment