You need to sign in to do that
Don't have an account?
CharlieLang
Apex testing problem
Hi All,
I am building some test code for some apex i created. When I have packaged everything up and deploying to another org i am getting an error as two of the fields i am referencing in the test code (TS_email__C and First_name__c) are being deployed as part of the package so they are not yet in the clients org.
Any help would be greatly appreciated
public static testMethod void tester() { User currentUserTest = [Select TS_email__c, First_name__c from User where username = :UserInfo.getUserName() limit 1]; System.runAs(currentUserTest) { buildit(); } }
Are you sending the User object fields in the package?, if not include them with the test class while migration.
Yeah. i'm including the 2 extra fields for the user object.
this is the error i'm getting
This problem is becuase of no data in the "currentUserTest ", so try like this
sorry for being really thick. where do i put it? I'm not particularly good at apex!
Here's the whole apex class.
thanks for your help in advance!!!!
try the above code.
and test code as
Ok. If i use the above, i only get a 70% code coverage.
whats the best way of increasing this?
Thanks for your help with this!!!