Ask Search:
Tara CharlesTara Charles 

Apex test error when uploading an Unmanaged Package

I am working on creating an Unmanaged Package of our Salesforce instance. I am running into an error that I don't know how to resolve. Any ideas on what I should try? I ran into a couple of these errors before and I made sure the fields were on the Custom Account object that it was referencing. 

Is it an issue with this field?: Is_this_a_Preferred_Partner__c for Custom_Account__c \

I also checked my overall Apex Test Class code coverage and it's only at 18%. I also have no idea how to resolve that. 

User-added image
Best Answer chosen by Tara Charles
Steve BlackwellSteve Blackwell
It looks to me like the Is_this_a_Preferred_Partner__c field doesn't exist, can you verify that it's on the object Custom_Account__c? I wasn't clear from your post if you had done that already or not.

Your low code coverage, especially if it's 18% for the whole org and not just this particular test class, is concerning. Anything under 75% and you'll hit issues deploying code to production. How to fix it is a rather detailed answer though, but in short, you'll need to write enough apex code tests to ensure 75% (or greater, greater always recommended) code coverage.

There's a lot of Apex Testing guides out there in Google, this one is just an intro:
https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods

All Answers

Steve BlackwellSteve Blackwell
It looks to me like the Is_this_a_Preferred_Partner__c field doesn't exist, can you verify that it's on the object Custom_Account__c? I wasn't clear from your post if you had done that already or not.

Your low code coverage, especially if it's 18% for the whole org and not just this particular test class, is concerning. Anything under 75% and you'll hit issues deploying code to production. How to fix it is a rather detailed answer though, but in short, you'll need to write enough apex code tests to ensure 75% (or greater, greater always recommended) code coverage.

There's a lot of Apex Testing guides out there in Google, this one is just an intro:
https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
This was selected as the best answer
Amit SinghAmit Singh
++ to Steve,
It looks to me like the Is_this_a_Preferred_Partner__c field doesn't exist, can you verify that it's on the object Custom_Account__c?

Seems that user had created that field earlier and then deleted that Please check MapCustomAccountFieldwithobjTest test class and AccountAfterUpdateAndInsert Trigger also check mapCustomAccountFieldwithContact class.

Also, May I suggest you to run All test cases before uploading the Package and make sure that all test cases pass successfully. 
 
Tara CharlesTara Charles
Hi Steve and Amit - Thanks for your quick responses! I just went back to double check the field, and I realized I made a typo! That explains why I got the same error again. I fixed that and uploaded the package again and it worked this time. Quick fix on that front.

I will tackle the issue of the code coverage now. Thank you for supplying that link to documentation. Much appreciated!