I'm trying to deploy from Sandbox to Production. I am running into Code coverage error. The code coverage in the developer console says 92%. But Change set deployment to production fails with the test coverage warning: "Average test coverage across all Apex classes and triggers is 74%, at least 75% test coverage is required.
-
Which Dev console. Prod or sandbox?– EricSep 29, 2017 at 4:24
-
1Do not run all tests while deploying the change set, select - Run Selected Tests and enter the test class names in the followed textarea.– Saumya GaikwadSep 29, 2017 at 5:18
-
@Eric Prod console– ChanduOct 3, 2017 at 4:24
-
@SaumyaGaikwad Thank you, I'll try run the test class separately– ChanduOct 3, 2017 at 4:25
1 Answer
I think it may be caused by validation rule/workflow/trigger throw error in your production.
Sometimes the overall coverage in production drops below 75%, even though it was at least 75% when the components were deployed from sandbox. Test methods that have dependencies on the organization’s data and metadata can cause a drop in code coverage. If the data and metadata have changed sufficiently to alter the result of dependent test methods, some methods can fail or behave differently. In that case, certain lines are no longer covered. - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_code_coverage_best_pract.htm