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
Nikunj VadiNikunj Vadi 

Code Coverage

Hi,
I have 82% code coverage in my dev org, when i am trying to upload my same package, it says 'Package upload failed' with below error .
all my triggers have some code coverage and all test methods have been passed successfully as i 'run all tests'.
"Average test coverage across all Apex Classes and Triggers is 58%, at least 75% test coverage is required."
Please help me out.
Is 'seeAllData=True' notation has any impact on this isuues? because i used 'seealldata' in some test methods.

SeAlVaSeAlVa

Hi Nikunj, 

 

you will probably be relaying on some data in your tests that is in your dev ORG but not in your Production ORG.

 

Basically, your data-set in your dev-org makes your tests cover more code than the data-set in your production-org (one of the problems that forcing seeAllData=true was trying to avoid).

 

You might need to

  a) Change your tests to add this records so they'll cover that missing code

  b) Create data in production org to meet what you need ( STRONGLY  UNRECOMENDED)

 

As a general piece of advice, don't use seeAllData=true unless you have no other option or if you are completely sure that the records you access in your tests will be available on production.

 

Kind regards.

KodiKodi

Hi,

 

Because your developer account has apex trigger and apex class means it should cover atleast 75% and also if you run all test classes will cover 75%. so then only you have to create a package.otherwise it's upload failed