+ Start a Discussion
karthik Jonnalagaddakarthik Jonnalagadda 

Code coverage failure

Hello all,

While I am pushing sandbox stuff to production I am getting the code coverage error Please anyone suggest the solution.User-added image
Best Answer chosen by karthik Jonnalagadda
KaranrajKaranraj
Karthik - The deployment is failed due to the test class failure in your production instances so your deployment component unable to cover the code coverage of 75% By seeing your attachement the class 'banchboxProcessingEscrowAPItest' is failed when eecuting the trigger SetlsCopiedToProjectFlagTrue in the line 12 your query is not returning any value and there is no proper exception is handled in the trigger code for that scenario so your test class gets failed once you fixed all the error message your code coverage will increase. For the best practices, validate your component before you deploying in production.

To understand better about Apex Test class, check this Trailhead module - https://developer.salesforce.com/trailhead/force_com_dev_beginner/apex_testing/apex_testing_intro

Thanks,
Karanraj

All Answers

Virendra ChouhanVirendra Chouhan
For pushing your code from sandbox to Prod you must have at least 75% code coverage.
so first write test classes to cover all your triggers and APEX classes.
KaranrajKaranraj
Karthik - The deployment is failed due to the test class failure in your production instances so your deployment component unable to cover the code coverage of 75% By seeing your attachement the class 'banchboxProcessingEscrowAPItest' is failed when eecuting the trigger SetlsCopiedToProjectFlagTrue in the line 12 your query is not returning any value and there is no proper exception is handled in the trigger code for that scenario so your test class gets failed once you fixed all the error message your code coverage will increase. For the best practices, validate your component before you deploying in production.

To understand better about Apex Test class, check this Trailhead module - https://developer.salesforce.com/trailhead/force_com_dev_beginner/apex_testing/apex_testing_intro

Thanks,
Karanraj
This was selected as the best answer