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
HealthDetail DevelopmentHealthDetail Development 

Managed Package Upload Failing with 1% Test Coverage - Org has 90%

I believe this is a Salesforce issue but will post here since they are insisting I do so.

We have developed a managed package ~4 yrs ago. On AppExchange, etc. We have been able to upload new versions fine if they just contain native changes such as new fields, objects, etc. Recently we added a Permission Set. The package upload is failing with error of 1% test coverage. Seems to happen with any new Apex added.

Our org has 90% coverage. We have tried recompiling all classes and rerunning many times. We are not accidentally pulling anything else into the package, it's just 1 permission set. We tried removing the Perm set and just adding a 2 line Apex class and upload to beta. Fails for same reason. Seems to run tests when Apex added...but calc is wrong. Any ideas?
Best Answer chosen by HealthDetail Development
HealthDetail DevelopmentHealthDetail Development
Thanks for reply, I had neglected to provide an update.

This wasn't first time I had encountered this problem and it is definitely a "bug". The fix was that we added an Apex Class to the managed package. Somehow this then made the package upload recalculate code coverage again and this time it was more accurate ~85%. This had nothing to do with us because the addition of that small class did not move the code coverage from 1% to 85%. I'm not sure if the system is caching the coverage or what happens behind scenes but the addition of an Apex Class to the Managed Package did the trick.

All Answers

Rahul KumarRahul Kumar (Salesforce Developers) 
Hi,

Are you trying to upload a package from Production org? If that is the case this is not a right way, ideally, you should be creating an unmanaged/managed package from Developer Edition(DE Org). What kind of error are you getting in upload? If errors are related to testing failure then those test methods must pass.
Best Regards
Rahul Kumar

 
HealthDetail DevelopmentHealthDetail Development
Thanks for reply, I had neglected to provide an update.

This wasn't first time I had encountered this problem and it is definitely a "bug". The fix was that we added an Apex Class to the managed package. Somehow this then made the package upload recalculate code coverage again and this time it was more accurate ~85%. This had nothing to do with us because the addition of that small class did not move the code coverage from 1% to 85%. I'm not sure if the system is caching the coverage or what happens behind scenes but the addition of an Apex Class to the Managed Package did the trick.
This was selected as the best answer