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
Jeff_SFJeff_SF 

Code Coverage Failure API Version?

AM having some issues deploying a small change for a trigger and adding a new trigger.  I am getting only19% coverage even though a previous developer has written a test class for all triggers a few years ago.  The api version for most triggers and testclass is 18.0.  the new trigger is api version 39.  could this have anything to do with why the coverage is so low?  What would be the best way to remedy this issue.?  Thank you
Maharajan CMaharajan C
Try Update the new API version:

If the trigger is already presented in production Use Eclipse IDE to change the version...

1.  Edit the trigger in my UAT sandbox environment to update the API version.
2.  Test trigger to validate that it functions in the new API version.
3.  Open Eclipse, and, in the project which corresponds to my sandbox, refresh the trigger from SalesForce.
4.  Deploy the trigger to production using the 'Deploy to SalesForce' option in the toolkit. 

Thanks
Ankit Maheshwari 2Ankit Maheshwari 2
Hi Jeff_SF,

I would like to suggest you that please check all the validations on the object and then check the class and trigger in developer console. You will get idea where issue occured. So you need to do some changes in test class as per requirement. 

Could you please try this once?

Thanks
James LoghryJames Loghry

Prior to API version 18 test classes defaulted to seeing all your org data.  This meant that developers tended to rely on existing organization data for their test classes.  You can actually still use existing data in your test class by setting "SeeAllData=true" although I highly recommend against it.  In other words, I'm thinking your unit test relies on existing data, which has since changed or been deleted and broken your unit tests.

To fix this, make sure your unit test class (not necessarily the trigger that it invokes) is on a recent API version and that it creates any necessary test data instead of relying on existing data in your org.