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
DuckyDucky 

Deploy to a production org always throw coverage error.

I know the rule of 75% test coverage. But this situation really weird. Could anyone please help me out of this hard situation. I am stuck at the last step whose flow is described as below:

1. At first, I created Apex classes / Apex pages at a Trial production Org (org A) which received from the client.
2. I also create few test classes and it ran well that time.
3. The client asked us to move to sandbox Org (org B) to continue developing. All the metadata was transferred without any problem.
4. then client upgrade org A to active production Org (that means I could not touch the apex class/page in this org anymore)
5. Then now I could not deploy apex code / pages from org B to org A at all because whenever I try to deploy, the system runs the test class in org A and always throw out a coverage error. The main point is, test classes in org A were created from step 2, their coverage is not enough or even they are not correct at all. So I'm trying to make it meet the constraint, but Salesforce refused??

I noticed that system always and only run the old test class in org A, it is so weird. Why does Salesforce run the old code which I want to override? If they want to check the correctness or test coverage of the current system, they should also check at step 4 and alert users to complete the constraint. Actually, I don't know how to handle this situation. Could anyone help me. 

Thanks in advance.
Heather ThompsonHeather Thompson
If you include the updated test class in your change set/package Salesforce will use the updated test class to test. Otherwise it will run all the old tests by default. It sounds like you might not be including the updated test classes in your deployment?