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
Steve CairneySteve Cairney 

Apex testing - Not getting package coverage

Hi, I've created a few classes and in order to make life easy, I've decided to create a package for ease of pushing the change over to my production org.

I've never tried this approach before, so I may be missing something.

I can confirm that all the classes and controllers pass with over 75% when testing in the developer console. However, when I try to upload the package, the average test coverage is only 57%

Why could that be happening?

I'd really rather not create a change set as the are are 6 custom objects at least...
Best Answer chosen by Steve Cairney
TintuBabuTintuBabu
Hi,

While packaging all dependent components will be automatically added to package and coverage of all classes which referes uploaded components will be taken into account. That might be the reason it shows reduced coverage.
Please do this to get actual code coverage before packaging. Go to developer console->Test-Check Run asynchronously->Run All.

Afetr that from setup->Apex Classes. At the top of the apex class listing there will be two links Do Compile All classes.After compiling Click Estimate Organisations Code coverage. That will be the code coverage refered while packaging. If that give s 57% you have to improve your code coverage of classes which refers any of the uploaded component  .

All Answers

TintuBabuTintuBabu
Hi,

While packaging all dependent components will be automatically added to package and coverage of all classes which referes uploaded components will be taken into account. That might be the reason it shows reduced coverage.
Please do this to get actual code coverage before packaging. Go to developer console->Test-Check Run asynchronously->Run All.

Afetr that from setup->Apex Classes. At the top of the apex class listing there will be two links Do Compile All classes.After compiling Click Estimate Organisations Code coverage. That will be the code coverage refered while packaging. If that give s 57% you have to improve your code coverage of classes which refers any of the uploaded component  .
This was selected as the best answer
Steve CairneySteve Cairney
Great, thanks for the steps. I'm at 81%