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
geetforcegeetforce 

getting NULL from Custom Settings in Test class

Hi All, I wrote a test case where I am fetching values from Custom Settings by executing "My_Settings.getValues('Test').myVal__c" statement. Here I am getting NULL POINTER ERROR because "My_Settings.getValues('Test')" line is retuning NULL value but I am getting value when I execute same statement in my controller class even when I tried the same line in Developer console I am getting correct value. I have no idea why I am getting NPE here in the test case where the same test case was working from last month and no buddy modified anything here or any of dependent objects. Does anyone are facing same issue or any one have any idea how to fix this.
Best Answer chosen by Admin (Salesforce Developers) 
Starz26Starz26

Are you using api24.0?

 

if so, you may need to set (seealldata=true);

 

 

All Answers

Starz26Starz26

Are you using api24.0?

 

if so, you may need to set (seealldata=true);

 

 

This was selected as the best answer
Jerun JoseJerun Jose

Hi,

 

I am having a similar problem. Can you check the post at.

 

http://boards.developerforce.com/t5/Apex-Code-Development/Custom-Setting-data-causing-problem-in-Test-method/td-p/409391

 

Thanks,

 

Jerun Jose