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
a!a! 

Code coverage across all Apex Classes and Triggers is 69%, at least 75% test coverage is required

Hi to all,

 

I have made some code changes in 2 apex classes, when i deploying these two apex classes, it throughs an error like this

: Average Test Coverage across all Apex classes and Triggers is 69%, atleast 75% test coverage is required.

 

when i run those 2 test classes, its test coverage is 84% and 86%.

 

I have deployd with change sets and also i try with Eclipse, getting the same error.

 

Please help me on this error, colud you please suggest any ideas or suggestons it will be greatly apriciated.

 

 

Thanking You in Advance. 

Best Answer chosen by Admin (Salesforce Developers) 
Sonali BhardwajSonali Bhardwaj

When you deploy your code, salesforce calculates your total organization code coverage, not only for the classes you are deploying. Your individual classes code coverage might be 82/84 % but code coverage for your all classes is 69%. You need to increase your overall code coverage of the org.

You can go to apex classes pages, and click on "Estimate your organization's code coverage" to see your overall coverage of the org. This has to be 75+.

 

All Answers

Sonali BhardwajSonali Bhardwaj

When you deploy your code, salesforce calculates your total organization code coverage, not only for the classes you are deploying. Your individual classes code coverage might be 82/84 % but code coverage for your all classes is 69%. You need to increase your overall code coverage of the org.

You can go to apex classes pages, and click on "Estimate your organization's code coverage" to see your overall coverage of the org. This has to be 75+.

 
This was selected as the best answer
hpereirahpereira

Hello,

 

I don't think your problem is specific to these 2 classes but to overall code on your Org.

Were new classes or triggers added, without test classes being implemented?

 

Regards

a!a!

Thanks Bhardwaj,

 

in my sandbox, overall coverage is 71 %.

 

i have one more dout, i want to maintain same thing in the production also?

 

Thanks.

Sonali BhardwajSonali Bhardwaj

 

When you deploy your code to Production, sfdc runs all the test classes on production only, not on your sandbox. As you can't change any code on Production, you have to make changes in sandbox to make code coverage 75%+. So your production test coverage has to be 75%+ including your current deployment classes.

a!a!

Thanks alot,

 

But in my org some thirdpatry packages are installed, when am running all test classes, some of the package test classes are failed.

 

how can we increase code coverage for installed packages

 

 

vbsvbs
@a! - Managed packages do not count towards your org's test code coverage. For any issues with the test classes within the managed package you will need to get in touch with the managed package provider.
a!a!

Thanks VBS,

 

in my sandbox now code coverage is 77%, where as in production  code coverage is 62%, can i deploy the code from sandbox to production.

vbsvbs
If you are deploying - just try running a validate to make sure there are no errors. If there is an issue with code coverage then you may have to review the test classes to confirm they match both in sandbox and production.
a!a!

Now in my Samdbox code coverage is 75%, but am getting the error as

"Apex Classes and Triggers is 69%, at least 75% test coverage is require"

 

Please suggest me, is there any way to deploy the code.

 

Its Very Urgent, i want to deploy the code in Production.

 

 

Thanking you in Advance.

vbsvbs

The only alternative is to compare the test classes which have increased test class coverage on sandbox and include them in your deployment package/changeset. There is no alternative to deploying to production other than ensuring the test coverage requirement.

a!a!

Finally i deployed the code from Dev to Prod by increasing the code coverage in sandbox.

 

 

a!a!

Thanks to every one.