You need to sign in to do that
Don't have an account?

public static controller variables not visible in test classes
public with sharing class CustomObjectFactory { public class UserPrefsDefaults { public final String name = 'User Preferences'; public final String bestBetsView = 'MBB'; public final Integer maxPages = 5; public final Integer timeFrameDays = 3; public final Boolean showWhatIsNew = true; } public static UserPrefsDefaults userPrefsDefaults { get{ if (userPrefsDefaults==null){ UserPrefsDefaults userPrefsDefaultsobj= new UserPrefsDefaults(); //return userPrefsDefaultsobj; } return userPrefsDefaults; } }} on saving below test class im facing error @isTest private class TestCustomObjectFactory { static testMethod void testUserPrefsGetter() { System.assertNotEquals(null, CustomObjectFactory.userPrefsDefaults); // test initialization CustomObjectFactory.userPrefsDefaults = null; System.assertNotEquals(null, CustomObjectFactory.userPrefsDefaults); } }
You are getting this error because you are trying to set the variable without defining set property. (IN LINE 34)
To resolve it use this code:
Note: I would suggest not to use same class name for your object variable.
thanks!
All Answers
You are getting this error because you are trying to set the variable without defining set property. (IN LINE 34)
To resolve it use this code:
Note: I would suggest not to use same class name for your object variable.
thanks!