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
JamesForceJamesForce 

How to write testing code for static property?

1 public static String AvatarUploadFolderDevname {
2 get {
3 return AVATAR_UPLOAD_DEFAULT_FOLDER_DEVNAME;
4 }
}

I wrote line like String str = Class.AvatarUploadFolderDevname; this only cover line#3, leave line#1 as red, not covered
this only cover

Avidev9Avidev9
How about String str = Class.GetAvatarUploadFolderDevname; ?
Bhawani SharmaBhawani Sharma
What is value of "AVATAR_UPLOAD_DEFAULT_FOLDER_DEVNAME"?
could & rockcould & rock

Not working, already tried that

could & rockcould & rock
AVATAR_UPLOAD_DEFAULT_FOLDER_DEVNAME is a constant
could & rockcould & rock

I gues this oculd be related how code coverage is calculated. I did some reseach on that, without luck

sfdcfoxsfdcfox
Sometimes the code coverage system gets it wrong, and this could be one of those times. Try clearing the coverage, then re-executing the test.

Regardless, simply referencing the field (and thus invoking the getter) should be sufficient to include code coverage. We have a number of static variables in our project that are mostly covered (if not all).