function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shahab KhanShahab Khan 

My Change set is not able to deploy even have 85% overall code coverage

Hi,

My Change set is not able to deploy to production even have 85% overall code coverage in sandbox as shown below
User-added image
But in production it show 73% code coverage.
User-added image
Can any body help me how to fix this problem

Thanks in advance.
Best Answer chosen by Shahab Khan
Deepak Kumar ShyoranDeepak Kumar Shyoran
First go to your production and check the overall code coverage over there. And if you have enough code coverage by combining on Production + Component in your Change Sets then let us know the exact error you are getting during deployment of new Change sets.

To remove a Test only without removing the class for which that class is written doesn’t make any sense rather increase test coverage for the class already exist on Production and push new changes on Production.

All Answers

logontokartiklogontokartik
Does you production instance have any other classes that you are not considering?
Shahab KhanShahab Khan
I am considering all the classes and overall code coverage is 85% but still not able to deploy
Please help me.
Deepak Kumar ShyoranDeepak Kumar Shyoran
First run all your classes on production and check the overall code coverage on production, as when you deploy a change sets to production then Salesforce check for Overall code coverage which combine Production and your change sets code and by combining both it should be > 75 %.
Shahab KhanShahab Khan
I have run all the tests in production and overall code coverage is 73% in production.
Shahab KhanShahab Khan
If i remove some of these deployed change sets from prodcution and when production coverage is > 75 then i can deploy sandbox changes
I think this can be work what you say Deepak
User-added image
Waiting for your reply.
Chinmay BhusariChinmay Bhusari
Yup sure can
Deepak Kumar ShyoranDeepak Kumar Shyoran
Yes defiantly it'll work.
But I'll suggest to deploy some more test class with your change sets which already installed on your production but having less code coverage by increasing their code coverage as it's not a big issue to increase their code coverage instead to deploy your new change sets by uninstalling a previous one.

AshwaniAshwani
@shahab

Can you make sure that your triggers have atleast 1% of test of test coverage.
Shahab KhanShahab Khan
I have used Eclipse IDE to delete classes from production.
I have selected multiple classes and their test classes and deploy them though IDE the result is that all test classes deleted but main classes are still there in production, due to which test coverage of production down to 63%.
Can any body let me know how i can delete those classes from prodcution?

logontokartiklogontokartik
ok. the main classes might have dependancies which you need to clear first. The Apex class might have been used in a Visualforce Page, Component, part of a Trigger, or a batch job is scheduled. Make sure you remove all dependancies before deleting a class. 

Hope this helps.

Thank you
Deepak Kumar ShyoranDeepak Kumar Shyoran
Why you want to delete Main class ? Just increase the Test Coverage for that and include that in your change sets and deploy new change stets with that class on Production, By doing this you will be able to solve your problem as on production salesforce reRerun the new Class will be able to see the > 75 % code coverage.

As if you delete your main class then how will you cover the test coverage for Main class.
Hope you understand.
Shahab KhanShahab Khan
Deepak due to low test coverage of production i couldn't be able to deploy further changes that's why i have removed main classes from prodcution but now it still not deploying still saying code coverage error although i have overall 80+% in sandbox
Can you please help me? i will be very thank full to you
Shahab KhanShahab Khan
Please some body help me
Deepak Kumar ShyoranDeepak Kumar Shyoran
First go to your production and check the overall code coverage over there. And if you have enough code coverage by combining on Production + Component in your Change Sets then let us know the exact error you are getting during deployment of new Change sets.

To remove a Test only without removing the class for which that class is written doesn’t make any sense rather increase test coverage for the class already exist on Production and push new changes on Production.
This was selected as the best answer
Shahab KhanShahab Khan
Here is production overall code coverage 76%
User-added image

Here is sanbox over all code coverage 91%
User-added image

And the result is that it says 54%

User-added image

Please help me
Shahab KhanShahab Khan
Deepak please help me 
Waiting for your reply
Deepak Kumar ShyoranDeepak Kumar Shyoran
It show in your last snapshot  that your origination have 54% cove coverage and your previous snapshots says that you have enough code coverage , well in that case please make sure you have included all new Test classes in your Change Sets.
Shahab KhanShahab Khan
Deepak i have included all new and updated test classes i have checked twice.
Can you please let me know how 54% is calculated or suggest me some other solution.
Deepak Kumar ShyoranDeepak Kumar Shyoran
Well in that case I think I need to review your org is that  all I can do for you :)
Shahab KhanShahab Khan
Deepak can i send one of my class code to you here for review?
Shahab KhanShahab Khan
I have figure out the problem i was referencing campaign id in test classes which was not in production due to which my code coverage was down.
Deepak Kumar ShyoranDeepak Kumar Shyoran
Congrats finally after a long discussion you will able to Deploy your code on Production.
Good job and it time to close your Question by selecting a best answer for your question.